mirror of
https://github.com/HChaZZY/alist.git
synced 2025-12-06 11:03:49 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56b3b35556 | ||
|
|
a7a0e85a46 | ||
|
|
95c0106fdd | ||
|
|
6612338fc1 | ||
|
|
c276a1541f | ||
|
|
cc96a5bbdb | ||
|
|
0810561a8a | ||
|
|
82a5c43b94 | ||
|
|
d38f36ef44 | ||
|
|
f9533440c7 | ||
|
|
41a186b051 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -22,6 +22,7 @@ dist/
|
|||||||
# vendor/
|
# vendor/
|
||||||
bin/*
|
bin/*
|
||||||
/alist
|
/alist
|
||||||
|
/alist.exe
|
||||||
*.json
|
*.json
|
||||||
public/*.html
|
public/*.html
|
||||||
public/assets/
|
public/assets/
|
||||||
|
|||||||
@@ -87,4 +87,4 @@ The `AList` is open-source software licensed under the AGPL-3.0 license.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> [@Blog](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@TelegramGroup](https://t.me/alist_chat) · [@QQGroup](https://jq.qq.com/?_wv=1027&k=OVPJcv2b)
|
> [@Blog](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@TelegramGroup](https://t.me/alist_chat) · [@QQGroup](https://jq.qq.com/?_wv=1027&k=YJJj2Gwb)
|
||||||
@@ -87,4 +87,4 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> [@Blog](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@TelegramGroup](https://t.me/alist_chat) · [@QQGroup](https://jq.qq.com/?_wv=1027&k=OVPJcv2b)
|
> [@博客](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@Telegram群](https://t.me/alist_chat) · [@QQ群](https://jq.qq.com/?_wv=1027&k=YJJj2Gwb)
|
||||||
1
alist.go
1
alist.go
@@ -12,7 +12,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Init() bool {
|
func Init() bool {
|
||||||
//bootstrap.InitLog()
|
|
||||||
bootstrap.InitConf()
|
bootstrap.InitConf()
|
||||||
bootstrap.InitCron()
|
bootstrap.InitCron()
|
||||||
bootstrap.InitModel()
|
bootstrap.InitModel()
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/url"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestUrl(t *testing.T) {
|
|
||||||
s,_ := url.QueryUnescape("/ali/%E7%8C%AA%E5%A4%B4%E7%9A%84%E6%96%87%E4%BB%B6%5B%E5%98%BF%E5%98%BF%5D/%E9%82%B9%E9%82%B9%E7%9A%84%E6%96%87%E4%BB%B6/%E6%A1%8C%E9%9D%A2%E5%A3%81%E7%BA%B8/v2-e8f266ba17ae387eefed1cb22b2b5e4e_r.jpg")
|
|
||||||
fmt.Print(s)
|
|
||||||
}
|
|
||||||
16
build.sh
16
build.sh
@@ -51,16 +51,8 @@ BUILD() {
|
|||||||
gitTag=$(git describe --long --tags --dirty --always)
|
gitTag=$(git describe --long --tags --dirty --always)
|
||||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
echo "build version: $gitTag"
|
echo "build version: $gitTag"
|
||||||
|
|
||||||
ldflags="\
|
ldflags="\
|
||||||
-w -s --extldflags '-static -fpic' \
|
|
||||||
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
|
||||||
-X 'github.com/Xhofe/alist/conf.GoVersion=$goVersion' \
|
|
||||||
-X 'github.com/Xhofe/alist/conf.GitAuthor=$gitAuthor' \
|
|
||||||
-X 'github.com/Xhofe/alist/conf.GitCommit=$gitCommit' \
|
|
||||||
-X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \
|
|
||||||
-X 'github.com/Xhofe/alist/conf.WebTag=$webTag' \
|
|
||||||
"
|
|
||||||
ldflagsDarwin="\
|
|
||||||
-w -s \
|
-w -s \
|
||||||
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||||
-X 'github.com/Xhofe/alist/conf.GoVersion=$goVersion' \
|
-X 'github.com/Xhofe/alist/conf.GoVersion=$goVersion' \
|
||||||
@@ -70,11 +62,9 @@ BUILD() {
|
|||||||
-X 'github.com/Xhofe/alist/conf.WebTag=$webTag' \
|
-X 'github.com/Xhofe/alist/conf.WebTag=$webTag' \
|
||||||
"
|
"
|
||||||
if [ "$1" == "release" ]; then
|
if [ "$1" == "release" ]; then
|
||||||
xgo -targets=linux/*,windows/* -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
||||||
xgo -targets=darwin/* -out "$appName" -ldflags="$ldflagsDarwin" -tags=jsoniter .
|
|
||||||
else
|
else
|
||||||
xgo -targets=linux/amd64,windows/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
xgo -targets=linux/amd64,windows/amd64,darwin/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
||||||
xgo -targets=darwin/amd64 -out "$appName" -ldflags="$ldflagsDarwin" -tags=jsoniter .
|
|
||||||
fi
|
fi
|
||||||
mkdir -p "build"
|
mkdir -p "build"
|
||||||
mv alist-* build
|
mv alist-* build
|
||||||
|
|||||||
@@ -291,6 +291,13 @@ func (s *State) Request(method string, fullUrl string, params Params, callback f
|
|||||||
return nil, fmt.Errorf(erron.Msg)
|
return nil, fmt.Errorf(erron.Msg)
|
||||||
}
|
}
|
||||||
if erron.ErrorCode != "" {
|
if erron.ErrorCode != "" {
|
||||||
|
switch erron.ErrorCode {
|
||||||
|
case "InvalidSessionKey":
|
||||||
|
if err := s.RefreshSession(account); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.Request(method, fullUrl, params, callback, account)
|
||||||
|
}
|
||||||
return nil, fmt.Errorf(erron.ErrorMsg)
|
return nil, fmt.Errorf(erron.ErrorMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ func (driver Native) Files(path string, account *model.Account) ([]model.File, e
|
|||||||
time := f.ModTime()
|
time := f.ModTime()
|
||||||
file := model.File{
|
file := model.File{
|
||||||
Name: f.Name(),
|
Name: f.Name(),
|
||||||
Size: f.Size(),
|
|
||||||
Type: 0,
|
Type: 0,
|
||||||
UpdatedAt: &time,
|
UpdatedAt: &time,
|
||||||
Driver: driver.Config().Name,
|
Driver: driver.Config().Name,
|
||||||
@@ -112,6 +111,7 @@ func (driver Native) Files(path string, account *model.Account) ([]model.File, e
|
|||||||
file.Type = conf.FOLDER
|
file.Type = conf.FOLDER
|
||||||
} else {
|
} else {
|
||||||
file.Type = utils.GetFileType(filepath.Ext(f.Name()))
|
file.Type = utils.GetFileType(filepath.Ext(f.Name()))
|
||||||
|
file.Size = f.Size()
|
||||||
}
|
}
|
||||||
files = append(files, file)
|
files = append(files, file)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ func (driver Onedrive) Items() []base.Item {
|
|||||||
Label: "redirect uri",
|
Label: "redirect uri",
|
||||||
Type: base.TypeString,
|
Type: base.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
|
Default: "https://tool.nn.ci/onedrive/callback",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "refresh_token",
|
Name: "refresh_token",
|
||||||
|
|||||||
@@ -245,12 +245,18 @@ func (s *State) Request(method string, url string, callback func(*resty.Request)
|
|||||||
log.Debug(res.String())
|
log.Debug(res.String())
|
||||||
|
|
||||||
var e Erron
|
var e Erron
|
||||||
utils.Json.Unmarshal(res.Body(), &e)
|
err = utils.Json.Unmarshal(res.Body(), &e)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
switch e.ErrorCode {
|
switch e.ErrorCode {
|
||||||
case 9:
|
case 9:
|
||||||
s.newCaptchaToken(getAction(method, url), nil, account)
|
_, err = s.newCaptchaToken(getAction(method, url), nil, account)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
case 4122, 4121:
|
case 4122, 4121: // Authorization expired
|
||||||
return s.Request(method, url, callback, account)
|
return s.Request(method, url, callback, account)
|
||||||
case 0:
|
case 0:
|
||||||
if res.StatusCode() == http.StatusOK {
|
if res.StatusCode() == http.StatusOK {
|
||||||
|
|||||||
@@ -4,9 +4,3 @@ import "embed"
|
|||||||
|
|
||||||
//go:embed *
|
//go:embed *
|
||||||
var Public embed.FS
|
var Public embed.FS
|
||||||
|
|
||||||
////go:embed index.html
|
|
||||||
//var Index embed.FS
|
|
||||||
//
|
|
||||||
////go:embed assets/**
|
|
||||||
//var Assets embed.FS
|
|
||||||
|
|||||||
Reference in New Issue
Block a user