Compare commits

...

10 Commits

Author SHA1 Message Date
ac8476702c 🐛 refer to https://github.com/ad-m/github-push-action/issues/44#issuecomment-581706892 2021-11-05 20:52:50 +08:00
12f68eaed9 💚 fix upload asserts 2021-11-05 19:47:02 +08:00
6a51f02845 💚 mv build.sh 2021-11-05 19:11:39 +08:00
e7071e1093 release asserts files cdn 2021-11-05 19:03:54 +08:00
11b141b190 update onedrive account status 2021-11-05 16:32:20 +08:00
7e099b39cf cache len(files)=0: request 2021-11-05 16:30:50 +08:00
b46bf0dfc9 🐛 delete beta1 meta 2021-11-04 23:25:53 +08:00
91f64161b2 💚 change back to ubuntu 2021-11-04 22:38:08 +08:00
8255ef4346 💚 print md5 2021-11-04 21:34:52 +08:00
254b6c6f79 print build version 2021-11-04 18:42:27 +08:00
7 changed files with 101 additions and 77 deletions

View File

@ -10,7 +10,7 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
platform: [macos-latest] platform: [ubuntu-latest]
go-version: [1.17] go-version: [1.17]
name: Build name: Build
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
@ -25,8 +25,8 @@ jobs:
with: with:
node-version: '16' node-version: '16'
- name: Setup docker # - name: Setup docker
uses: docker-practice/actions-setup-docker@master # uses: docker-practice/actions-setup-docker@master
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -45,20 +45,12 @@ jobs:
run: | run: |
docker pull techknowlogick/xgo:latest docker pull techknowlogick/xgo:latest
go install src.techknowlogick.com/xgo@latest go install src.techknowlogick.com/xgo@latest
brew install upx sudo apt install upx
- name: Build web
run: |
cd alist-web
yarn
yarn build
cd ..
- name: Build - name: Build
run: | run: |
cd alist mv alist/build.sh .
bash build.sh bash build.sh
cd ..
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2

View File

@ -9,7 +9,7 @@ jobs:
release: release:
strategy: strategy:
matrix: matrix:
platform: [macos-latest] platform: [ubuntu-latest]
go-version: [1.17] go-version: [1.17]
name: Release name: Release
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
@ -19,8 +19,8 @@ jobs:
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- name: Setup docker # - name: Setup docker
uses: docker-practice/actions-setup-docker@master # uses: docker-practice/actions-setup-docker@master
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v2 uses: actions/setup-node@v2
@ -32,6 +32,8 @@ jobs:
with: with:
ref: v2 ref: v2
path: alist path: alist
persist-credentials: false
fetch-depth: 0
- name: Checkout web repo - name: Checkout web repo
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -39,25 +41,27 @@ jobs:
repository: Xhofe/alist-web repository: Xhofe/alist-web
ref: v2 ref: v2
path: alist-web path: alist-web
persist-credentials: false
fetch-depth: 0
- name: Set up xgo - name: Set up xgo
run: | run: |
docker pull techknowlogick/xgo:latest docker pull techknowlogick/xgo:latest
go install src.techknowlogick.com/xgo@latest go install src.techknowlogick.com/xgo@latest
brew install upx sudo apt install upx
- name: Build web
run: |
cd alist-web
yarn
yarn build
cd ..
- name: Build - name: Build
run: | run: |
cd alist mv alist/build.sh .
bash build.sh release bash build.sh release
cd ..
- name: Upload asserts files
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.MY_TOKEN }}
branch: cdn
directory: alist-web
repository: Xhofe/alist-web
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1

View File

@ -30,7 +30,7 @@ func Init() {
func main() { func main() {
if conf.Version { if conf.Version {
fmt.Printf("Built At: %s\nGo Version: %s\nAuthor: %s\nCommit ID: %s\nVersion:%s\n", conf.BuiltAt, conf.GoVersion, conf.GitAuthor, conf.GitCommit, conf.GitTag) fmt.Printf("Built At: %s\nGo Version: %s\nAuthor: %s\nCommit ID: %s\nVersion: %s\n", conf.BuiltAt, conf.GoVersion, conf.GitAuthor, conf.GitCommit, conf.GitTag)
return return
} }
Init() Init()

View File

@ -1,5 +1,18 @@
#!/bin/bash #!/bin/bash
cd alist-web || exit
webCommit=$(git log --pretty=format:"%h" -1)
echo "web commit id: $webCommit"
yarn
if [ "$1" == "release" ]; then
yarn build --base="https://cdn.jsdelivr.net/gh/Xhofe/alist-web@cdn/v2/$webCommit"
mv dist/assets ..
else
yarn build
fi
cd ..
cd alist
appName="alist" appName="alist"
builtAt="$(date +'%F %T %z')" builtAt="$(date +'%F %T %z')"
goVersion=$(go version | sed 's/go version //') goVersion=$(go version | sed 's/go version //')
@ -9,9 +22,11 @@ gitCommit=$(git log --pretty=format:"%h" -1)
if [ "$1" == "release" ]; then if [ "$1" == "release" ]; then
gitTag=$(git describe --abbrev=0 --tags) gitTag=$(git describe --abbrev=0 --tags)
else else
gitTag=$(git describe --abbrev=0 --tags)-next gitTag=build-next
fi fi
echo "build version: $gitTag"
ldflags="\ ldflags="\
-w -s \ -w -s \
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \ -X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
@ -33,7 +48,7 @@ mv alist-* build
cd build || exit cd build || exit
upx -9 ./* upx -9 ./*
find . -type f -print0 | xargs -0 md5sum > md5.txt find . -type f -print0 | xargs -0 md5sum > md5.txt
cat md5.txt
# compress file (release) # compress file (release)
if [ "$1" == "release" ]; then if [ "$1" == "release" ]; then
mkdir compress mkdir compress
@ -51,3 +66,16 @@ if [ "$1" == "release" ]; then
zip compress/$(echo $i | sed 's/\.[^.]*$//').zip "$i" zip compress/$(echo $i | sed 's/\.[^.]*$//').zip "$i"
done done
fi fi
cd ../..
if [ "$1" == "release" ]; then
cd alist-web
git checkout cdn
mkdir "v2/$webCommit"
mv ../assets/ v2/$webCommit
git add .
git config --local user.email "i@nn.ci"
git config --local user.name "Xhofe"
git commit --allow-empty -m "upload $webCommit assets files" -a
cd ..
fi

View File

@ -221,13 +221,16 @@ func (a AliDrive) Path(path string, account *model.Account) (*model.File, []*mod
return a.FormatFile(&file), nil, nil return a.FormatFile(&file), nil, nil
} else { } else {
files, _ := cache.([]AliFile) files, _ := cache.([]AliFile)
if len(files) != 0 {
res := make([]*model.File, 0) res := make([]*model.File, 0)
for _, file = range files { for _, file = range files {
res = append(res, a.FormatFile(&file)) res = append(res, a.FormatFile(&file))
} }
return nil, res, nil return nil, res, nil
} }
} else { }
}
// no cache or len(files) == 0
fileId := account.RootFolder fileId := account.RootFolder
if path != "/" { if path != "/" {
dir, name := filepath.Split(path) dir, name := filepath.Split(path)
@ -269,7 +272,6 @@ func (a AliDrive) Path(path string, account *model.Account) (*model.File, []*mod
res = append(res, a.FormatFile(&file)) res = append(res, a.FormatFile(&file))
} }
return nil, res, nil return nil, res, nil
}
} }
func (a AliDrive) Link(path string, account *model.Account) (string, error) { func (a AliDrive) Link(path string, account *model.Account) (string, error) {
@ -316,10 +318,12 @@ func (a AliDrive) RefreshToken(account *model.Account) error {
SetError(&e). SetError(&e).
Post(url) Post(url)
if err != nil { if err != nil {
account.Status = err.Error()
return err return err
} }
log.Debugf("%+v,%+v", resp, e) log.Debugf("%+v,%+v", resp, e)
if e.Code != "" { if e.Code != "" {
account.Status = e.Message
return fmt.Errorf("failed to refresh token: %s", e.Message) return fmt.Errorf("failed to refresh token: %s", e.Message)
} }
account.RefreshToken, account.AccessToken = resp.RefreshToken, resp.AccessToken account.RefreshToken, account.AccessToken = resp.RefreshToken, resp.AccessToken
@ -354,9 +358,6 @@ func (a AliDrive) Save(account *model.Account, old *model.Account) error {
return return
} }
err = a.RefreshToken(&newAccount) err = a.RefreshToken(&newAccount)
if err != nil {
newAccount.Status = err.Error()
}
_ = model.SaveAccount(newAccount) _ = model.SaveAccount(newAccount)
}) })
if err != nil { if err != nil {

View File

@ -146,9 +146,11 @@ func (o Onedrive) RefreshToken(account *model.Account) error {
"refresh_token": account.RefreshToken, "refresh_token": account.RefreshToken,
}).Post(url) }).Post(url)
if err != nil { if err != nil {
account.Status = err.Error()
return err return err
} }
if e.Error != "" { if e.Error != "" {
account.Status = e.ErrorDescription
return fmt.Errorf("%s", e.ErrorDescription) return fmt.Errorf("%s", e.ErrorDescription)
} }
account.RefreshToken, account.AccessToken = resp.RefreshToken, resp.AccessToken account.RefreshToken, account.AccessToken = resp.RefreshToken, resp.AccessToken
@ -280,9 +282,6 @@ func (o Onedrive) Save(account *model.Account, old *model.Account) error {
return return
} }
err = o.RefreshToken(&newAccount) err = o.RefreshToken(&newAccount)
if err != nil {
newAccount.Status = err.Error()
}
_ = model.SaveAccount(newAccount) _ = model.SaveAccount(newAccount)
}) })
if err != nil { if err != nil {

View File

@ -32,7 +32,7 @@ func SaveMeta(ctx *fiber.Ctx) error {
func DeleteMeta(ctx *fiber.Ctx) error { func DeleteMeta(ctx *fiber.Ctx) error {
path := ctx.Query("path") path := ctx.Query("path")
path = utils.ParsePath(path) //path = utils.ParsePath(path)
if err := model.DeleteMeta(path); err != nil { if err := model.DeleteMeta(path); err != nil {
return ErrorResp(ctx, err, 500) return ErrorResp(ctx, err, 500)
} }