Compare commits

...

37 Commits

Author SHA1 Message Date
微凉 4bcc6359e3 💚 fix docker build 2022-01-20 20:52:14 +08:00
微凉 4144afcc92 :bug: fix #397 139yun file size overflow int32 2022-01-20 20:35:01 +08:00
微凉 2ad27046fb 🎨 split build and docker 2022-01-20 20:30:58 +08:00
微凉 9516ac6718 🎇 finish move api 2022-01-20 19:58:25 +08:00
微凉 de638c7c36 :bug: fix 123pan move 2022-01-20 19:58:10 +08:00
微凉 c6b34a033b 🔧 add swf to image types 2022-01-20 14:40:59 +08:00
微凉 31de3399d2 💚 fix musl prebuilt 2022-01-20 14:23:31 +08:00
微凉 0dc2ca019f 💚 fix musl prebuilt 2022-01-20 13:47:21 +08:00
微凉 04724f7f0f 👷 add prebuilt for musl-libc 2022-01-20 12:53:49 +08:00
微凉 75a983a965 :bug: fix webdav can't get file with password 2022-01-19 18:46:32 +08:00
微凉 e12d8bb8ca ⬆️ upgrade gorm 2022-01-19 09:15:00 +08:00
微凉 68f1ccfed4 ✨ add sslmode for postgres 2022-01-19 09:14:31 +08:00
微凉 54272db59c 🚧 add folder api 2022-01-18 19:08:44 +08:00
微凉 6d34e88360 🎇 hide files while webdav visitor 2022-01-18 18:48:08 +08:00
微凉 0a901a2eb0 :bug: fix can't find zhimg for dev 2022-01-18 18:19:58 +08:00
微凉 e1671a0511 🚧 add move api 2022-01-18 16:13:07 +08:00
微凉 dcb4ec695f ✨ rename and mkdir api 2022-01-18 14:31:52 +08:00
微凉 4a21b6fe1d :fire: close res.body for proxy 2022-01-18 11:29:32 +08:00
微凉 96a237902b :bug: close #379 fix google drive can't get text file 2022-01-17 09:54:19 +08:00
微凉 cfb51e9f80 ✨ Extract folder 2022-01-16 16:38:41 +08:00
微凉 e952f1c243 :fire: Optimize 189 cloud get client 2022-01-16 16:05:32 +08:00
微凉 07d6ca27db :bug: Forbid MediaTrack to create a new folder with the same name 2022-01-16 13:21:29 +08:00
微凉 8245da485a :bug: fix s3 for #362 2022-01-15 20:24:57 +08:00
微凉 5c759217cf :bug: fix some lanzou can't down #360 2022-01-15 20:10:42 +08:00
微凉 0648fdebc2 ♻️ solve circular dependency 2022-01-15 19:59:24 +08:00
微凉 ed670e528f :bug: fix 139Yun error phone close #365 2022-01-15 19:44:22 +08:00
微凉 2473309a51 🎇 execute save while delete account 2022-01-15 19:36:37 +08:00
微凉 21ca2f11b7 🔧 change default config 2022-01-14 21:20:45 +08:00
微凉 ccaa28a323 🔧 change default cdn 2022-01-14 20:56:20 +08:00
微凉 fea8b376f8 🔧 change config 2022-01-14 20:10:35 +08:00
微凉 55d244b726 :bug: fix mediatrack can't mkdir #351 2022-01-14 18:19:58 +08:00
微凉 1640a52789 ✨ cancel hide file for admin #343 2022-01-14 18:00:47 +08:00
微凉 424ec10692 :bug: fix ftp download error 2022-01-13 22:56:07 +08:00
微凉 b472c2ee18 🔒 not allowed delete root folder 2022-01-13 21:23:27 +08:00
微凉 65a01251e9 :bug: fix proxy not set status 2022-01-13 20:09:11 +08:00
微凉 96be6bbbd1 :bug: fix #334 proxy video can't use range 2022-01-13 19:49:02 +08:00
微凉 6f7465aab7 :bug: fix 139Yun no user error 2022-01-13 18:01:54 +08:00
61 changed files with 933 additions and 403 deletions
+1 -38
View File
@@ -48,41 +48,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: artifact
path: alist/build
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: xhofe/alist
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Build web
run: |
bash build.sh web
mv dist/* public
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: xhofe
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
path: alist/build
+46
View File
@@ -0,0 +1,46 @@
name: build_docker
on:
push:
branches: [ v2 ]
pull_request:
branches: [ v2 ]
jobs:
build_docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: xhofe/alist
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Build web
run: |
bash build.sh web
mv dist/* public
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: xhofe
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
+1 -38
View File
@@ -43,41 +43,4 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v1
with:
files: alist/build/compress/*
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: xhofe/alist
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Build web
run: |
bash build.sh cdn
mv dist/* public
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: xhofe
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
files: alist/build/compress/*
+45
View File
@@ -0,0 +1,45 @@
name: release_docker
on:
push:
tags:
- '*'
jobs:
docker_release:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: xhofe/alist
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Build web
run: |
bash build.sh cdn
mv dist/* public
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: xhofe
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
+1 -1
View File
@@ -23,7 +23,7 @@ dist/
bin/*
/alist
*.json
public/index.html
public/*.html
public/assets/
public/public/
data/
+1 -1
View File
@@ -3,7 +3,7 @@ LABEL stage=go-builder
WORKDIR /app/
COPY ./ ./
RUN apk add --no-cache bash git go gcc musl-dev; \
sh build.sh docker
bash build.sh docker
FROM alpine:edge
LABEL MAINTAINER="i@nn.ci"
+1 -1
View File
@@ -33,7 +33,7 @@ func InitConf() {
}
log.Debugf("config:%+v", conf.Conf)
// update config.json struct
confBody, err := utils.Json.Marshal(conf.Conf)
confBody, err := utils.Json.MarshalIndent(conf.Conf, "", " ")
if err != nil {
log.Fatalf("marshal config error:%s", err.Error())
}
+2 -3
View File
@@ -60,14 +60,13 @@ func InitModel() {
}
case "postgres":
{
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=disable TimeZone=Asia/Shanghai",
databaseConfig.Host, databaseConfig.User, databaseConfig.Password, databaseConfig.Name, databaseConfig.Port)
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=%s TimeZone=Asia/Shanghai",
databaseConfig.Host, databaseConfig.User, databaseConfig.Password, databaseConfig.Name, databaseConfig.Port, databaseConfig.SslMode)
db, err := gorm.Open(postgres.Open(dsn), gormConfig)
if err != nil {
log.Errorf("failed to connect database:%s", err.Error())
}
conf.DB = db
}
default:
log.Fatalf("not supported database type: %s", databaseConfig.Type)
+53 -8
View File
@@ -57,19 +57,63 @@ BUILD() {
if [ "$1" == "release" ]; then
xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
else
xgo -targets=linux/amd64,windows/amd64 -out alist -ldflags="$ldflags" -tags=jsoniter .
xgo -targets=linux/amd64,windows/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
fi
mkdir "build"
mkdir -p "build"
mv alist-* build
cd build
upx -9 ./*
find . -type f -print0 | xargs -0 md5sum >md5.txt
cat md5.txt
cd ../..
if [ "$1" != "release" ]; then
cd build
upx -9 ./*
find . -type f -print0 | xargs -0 md5sum >md5.txt
cat md5.txt
cd ..
fi
cd ..
}
BUILD_MUSL() {
BASE="https://musl.cc/"
FILES=(x86_64-linux-musl-cross aarch64-linux-musl-cross arm-linux-musleabihf-cross mips-linux-musl-cross mips64-linux-musl-cross mips64el-linux-musl-cross mipsel-linux-musl-cross powerpc64le-linux-musl-cross s390x-linux-musl-cross)
for i in "${FILES[@]}"; do
url="${BASE}${i}.tgz"
curl -L -o "${i}.tgz" "${url}"
sudo tar xf "${i}.tgz" --strip-components 1 -C /usr/local
done
cd alist
appName="alist"
builtAt="$(date +'%F %T %z')"
goVersion=$(go version | sed 's/go version //')
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
gitCommit=$(git log --pretty=format:"%h" -1)
gitTag=$(git describe --long --tags --dirty --always)
ldflags="\
-w -s \
-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' \
"
OS_ARCHES=(linux-musl-amd64 linux-musl-arm64 linux-musl-arm linux-musl-mips linux-musl-mips64 linux-musl-mips64le linux-musl-mipsle linux-musl-ppc64le linux-musl-s390x)
CGO_ARGS=(x86_64-linux-musl-gcc aarch64-linux-musl-gcc arm-linux-musleabihf-gcc mips-linux-musl-gcc mips64-linux-musl-gcc mips64el-linux-musl-gcc mipsel-linux-musl-gcc powerpc64le-linux-musl-gcc s390x-linux-musl-gcc)
for i in "${!OS_ARCHES[@]}"; do
os_arch=${OS_ARCHES[$i]}
cgo_cc=${CGO_ARGS[$i]}
echo building for ${os_arch}
export GOOS=${os_arch%%-*}
export GOARCH=${os_arch##*-}
export CC=${cgo_cc}
export CGO_ENABLED=1
go build -o ./build/$appName-$os_arch -ldflags="$ldflags" -tags=jsoniter alist.go
done
cd ..
}
RELEASE() {
cd alist/build
upx -9 ./*
find . -type f -print0 | xargs -0 md5sum >md5.txt
cat md5.txt
mkdir compress
mv md5.txt compress
for i in $(find . -type f -name "$appName-linux-*"); do
@@ -94,7 +138,8 @@ elif [ "$1" = "build" ]; then
BUILD build
elif [ "$1" = "release" ]; then
BUILD release
BUILD_MUSL
RELEASE
else
echo -e "${RED_COLOR} 错误的命令${RES}"
echo -e "${RED_COLOR} Parameter error ${RES}"
fi
+4 -1
View File
@@ -9,6 +9,7 @@ type Database struct {
Name string `json:"name"`
TablePrefix string `json:"table_prefix"`
DBFile string `json:"db_file"`
SslMode string `json:"ssl_mode"`
}
type Scheme struct {
@@ -25,7 +26,7 @@ type CacheConfig struct {
type Config struct {
Address string `json:"address"`
Port int `json:"port"`
Local bool `json:"local"`
Assets string `json:"assets"`
Database Database `json:"database"`
Scheme Scheme `json:"scheme"`
Cache CacheConfig `json:"cache"`
@@ -35,11 +36,13 @@ func DefaultConfig() *Config {
return &Config{
Address: "0.0.0.0",
Port: 5244,
Assets: "zhimg",
Database: Database{
Type: "sqlite3",
Port: 0,
TablePrefix: "x_",
DBFile: "data/data.db",
SslMode: "disable",
},
Cache: CacheConfig{
Expiration: 60,
+1 -1
View File
@@ -36,7 +36,7 @@ var (
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv"}
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav"}
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg", "ico"}
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg", "ico", "swf"}
)
var settingsMap = make(map[string]string, 0)
+4 -1
View File
@@ -65,6 +65,9 @@ func (driver Pan123) Items() []base.Item {
}
func (driver Pan123) Save(account *model.Account, old *model.Account) error {
if account == nil {
return nil
}
if account.RootFolder == "" {
account.RootFolder = "0"
}
@@ -234,7 +237,7 @@ func (driver Pan123) Move(src string, dst string, account *model.Account) error
}
parentFileId, _ := strconv.Atoi(dstDirFile.Id)
data := base.Json{
"fileId": fileId,
"fileIdList": []base.Json{{"FileId": fileId}},
"parentFileId": parentFileId,
}
_, err = driver.Request("https://www.123pan.com/api/file/mod_pid",
+2 -2
View File
@@ -136,7 +136,7 @@ func (driver Cloud139) GetFiles(catalogID string, account *model.Account) ([]mod
f := model.File{
Id: content.ContentID,
Name: content.ContentName,
Size: int64(content.ContentSize),
Size: content.ContentSize,
Type: utils.GetFileType(path.Ext(content.ContentName)),
Driver: driver.Config().Name,
UpdatedAt: getTime(content.UpdateTime),
@@ -158,7 +158,7 @@ func (driver Cloud139) GetLink(contentId string, account *model.Account) (string
"appName": "",
"contentID": contentId,
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
}
+16 -8
View File
@@ -64,6 +64,9 @@ func (driver Cloud139) Items() []base.Item {
}
func (driver Cloud139) Save(account *model.Account, old *model.Account) error {
if account == nil {
return nil
}
_, err := driver.Request("/orchestration/personalCloud/user/v1.0/qryUserExternInfo", base.Post, nil, nil, nil, base.Json{
"qryUserExternInfoReq": base.Json{
"commonAccountInfo": base.Json{
@@ -131,7 +134,12 @@ func (driver Cloud139) Link(args base.Args, account *model.Account) (*base.Link,
if err != nil {
return nil, err
}
u, err := driver.GetLink(file.Id, account)
var u string
//if isFamily(account) {
// u, err = driver.familyLink(file.Id, account)
//} else {
u, err = driver.GetLink(file.Id, account)
//}
if err != nil {
return nil, err
}
@@ -224,7 +232,7 @@ func (driver Cloud139) Move(src string, dst string, account *model.Account) erro
"newCatalogID": dstParentFile.Id,
},
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
},
@@ -249,7 +257,7 @@ func (driver Cloud139) Rename(src string, dst string, account *model.Account) er
"catalogID": srcFile.Id,
"catalogName": utils.Base(dst),
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
}
@@ -259,7 +267,7 @@ func (driver Cloud139) Rename(src string, dst string, account *model.Account) er
"contentID": srcFile.Id,
"contentName": utils.Base(dst),
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
}
@@ -298,7 +306,7 @@ func (driver Cloud139) Copy(src string, dst string, account *model.Account) erro
"newCatalogID": dstParentFile.Id,
},
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
},
@@ -330,7 +338,7 @@ func (driver Cloud139) Delete(path string, account *model.Account) error {
"catalogInfoList": contentInfoList,
},
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
},
@@ -341,7 +349,7 @@ func (driver Cloud139) Delete(path string, account *model.Account) error {
"catalogList": catalogInfoList,
"contentList": contentInfoList,
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
"sourceCatalogType": 1002,
@@ -377,7 +385,7 @@ func (driver Cloud139) Upload(file *model.FileStream, account *model.Account) er
"parentCatalogID": parentFile.Id,
"newCatalogName": "",
"commonAccountInfo": base.Json{
"account": "18627147660",
"account": account.Username,
"accountType": 1,
},
}
+1 -1
View File
@@ -43,7 +43,7 @@ func (driver Cloud139) familyGetFiles(catalogID string, account *model.Account)
f := model.File{
Id: content.ContentID,
Name: content.ContentName,
Size: int64(content.ContentSize),
Size: content.ContentSize,
Type: utils.GetFileType(path.Ext(content.ContentName)),
Driver: driver.Config().Name,
UpdatedAt: getTime(content.LastUpdateTime),
+35 -35
View File
@@ -40,7 +40,7 @@ type Content struct {
ContentID string `json:"contentID"`
ContentName string `json:"contentName"`
//ContentSuffix string `json:"contentSuffix"`
ContentSize int `json:"contentSize"`
ContentSize int64 `json:"contentSize"`
//ContentDesc string `json:"contentDesc"`
//ContentType int `json:"contentType"`
//ContentOrigin int `json:"contentOrigin"`
@@ -132,43 +132,43 @@ type UploadResp struct {
}
type CloudContent struct {
ContentID string `json:"contentID"`
Modifier string `json:"modifier"`
Nickname string `json:"nickname"`
CloudNickName string `json:"cloudNickName"`
ContentName string `json:"contentName"`
ContentType int `json:"contentType"`
ContentSuffix string `json:"contentSuffix"`
ContentSize int `json:"contentSize"`
ContentDesc string `json:"contentDesc"`
CreateTime string `json:"createTime"`
Shottime interface{} `json:"shottime"`
LastUpdateTime string `json:"lastUpdateTime"`
ThumbnailURL string `json:"thumbnailURL"`
MidthumbnailURL string `json:"midthumbnailURL"`
BigthumbnailURL string `json:"bigthumbnailURL"`
PresentURL string `json:"presentURL"`
PresentLURL string `json:"presentLURL"`
PresentHURL string `json:"presentHURL"`
ParentCatalogID string `json:"parentCatalogID"`
Uploader string `json:"uploader"`
UploaderNickName string `json:"uploaderNickName"`
TreeInfo interface{} `json:"treeInfo"`
UpdateTime interface{} `json:"updateTime"`
ExtInfo struct {
Uploader string `json:"uploader"`
} `json:"extInfo"`
EtagOprType interface{} `json:"etagOprType"`
ContentID string `json:"contentID"`
//Modifier string `json:"modifier"`
//Nickname string `json:"nickname"`
//CloudNickName string `json:"cloudNickName"`
ContentName string `json:"contentName"`
//ContentType int `json:"contentType"`
//ContentSuffix string `json:"contentSuffix"`
ContentSize int64 `json:"contentSize"`
//ContentDesc string `json:"contentDesc"`
//CreateTime string `json:"createTime"`
//Shottime interface{} `json:"shottime"`
LastUpdateTime string `json:"lastUpdateTime"`
ThumbnailURL string `json:"thumbnailURL"`
//MidthumbnailURL string `json:"midthumbnailURL"`
//BigthumbnailURL string `json:"bigthumbnailURL"`
//PresentURL string `json:"presentURL"`
//PresentLURL string `json:"presentLURL"`
//PresentHURL string `json:"presentHURL"`
//ParentCatalogID string `json:"parentCatalogID"`
//Uploader string `json:"uploader"`
//UploaderNickName string `json:"uploaderNickName"`
//TreeInfo interface{} `json:"treeInfo"`
//UpdateTime interface{} `json:"updateTime"`
//ExtInfo struct {
// Uploader string `json:"uploader"`
//} `json:"extInfo"`
//EtagOprType interface{} `json:"etagOprType"`
}
type CloudCatalog struct {
CatalogID string `json:"catalogID"`
CatalogName string `json:"catalogName"`
CloudID string `json:"cloudID"`
CreateTime string `json:"createTime"`
LastUpdateTime string `json:"lastUpdateTime"`
Creator string `json:"creator"`
CreatorNickname string `json:"creatorNickname"`
CatalogID string `json:"catalogID"`
CatalogName string `json:"catalogName"`
//CloudID string `json:"cloudID"`
//CreateTime string `json:"createTime"`
LastUpdateTime string `json:"lastUpdateTime"`
//Creator string `json:"creator"`
//CreatorNickname string `json:"creatorNickname"`
}
type QueryContentListResp struct {
+19 -4
View File
@@ -36,6 +36,22 @@ import (
var client189Map map[string]*resty.Client
func (driver Cloud189) getClient(account *model.Account) (*resty.Client, error) {
client, ok := client189Map[account.Name]
if ok {
return client, nil
}
err := driver.Login(account)
if err != nil {
return nil, err
}
client, ok = client189Map[account.Name]
if !ok {
return nil, fmt.Errorf("can't find [%s] client", account.Name)
}
return client, nil
}
func (driver Cloud189) FormatFile(file *Cloud189File) *model.File {
f := &model.File{
Id: strconv.FormatInt(file.Id, 10),
@@ -264,9 +280,9 @@ func (driver Cloud189) GetFiles(fileId string, account *model.Account) ([]Cloud1
}
func (driver Cloud189) Request(url string, method int, query, form map[string]string, headers map[string]string, account *model.Account) ([]byte, error) {
client, ok := client189Map[account.Name]
if !ok {
return nil, fmt.Errorf("can't find [%s] client", account.Name)
client, err := driver.getClient(account)
if err != nil {
return nil, err
}
//var resp base.Json
if driver.isFamily(account) {
@@ -293,7 +309,6 @@ func (driver Cloud189) Request(url string, method int, query, form map[string]st
if headers != nil {
req = req.SetHeaders(headers)
}
var err error
var res *resty.Response
switch method {
case base.Get:
+7 -4
View File
@@ -73,9 +73,12 @@ func (driver Cloud189) Items() []base.Item {
}
func (driver Cloud189) Save(account *model.Account, old *model.Account) error {
if old != nil && old.Name != account.Name {
if old != nil {
delete(client189Map, old.Name)
}
if account == nil {
return nil
}
if err := driver.Login(account); err != nil {
account.Status = err.Error()
_ = model.SaveAccount(account)
@@ -346,9 +349,9 @@ func (driver Cloud189) Upload(file *model.FileStream, account *model.Account) er
if file == nil {
return base.ErrEmptyFile
}
client, ok := client189Map[account.Name]
if !ok {
return fmt.Errorf("can't find [%s] client", account.Name)
client, err := driver.getClient(account)
if err != nil {
return err
}
parentFile, err := driver.File(file.ParentPath, account)
if err != nil {
+3
View File
@@ -67,6 +67,9 @@ func (driver AliDrive) Save(account *model.Account, old *model.Account) error {
if old != nil {
conf.Cron.Remove(cron.EntryID(old.CronId))
}
if account == nil {
return nil
}
if account.RootFolder == "" {
account.RootFolder = "root"
}
+3
View File
@@ -48,6 +48,9 @@ func (driver Alist) Items() []base.Item {
}
func (driver Alist) Save(account *model.Account, old *model.Account) error {
if account == nil {
return nil
}
account.SiteUrl = strings.TrimRight(account.SiteUrl, "/")
if account.RootFolder == "" {
account.RootFolder = "/"

Some files were not shown because too many files have changed in this diff Show More