From 2e73857b420e72bec8d20cda2befc455d82a8b8f Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:50:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=BF=AB=E7=85=A7=E8=B7=AF=E5=BE=84=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#1863)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/backup.go | 6 +++++- backend/utils/cloud_storage/client/onedrive.go | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/app/service/backup.go b/backend/app/service/backup.go index 548c062c..4adfb5aa 100644 --- a/backend/app/service/backup.go +++ b/backend/app/service/backup.go @@ -282,7 +282,11 @@ func (u *BackupService) ListFiles(req dto.BackupSearchFile) ([]interface{}, erro if err != nil { return nil, err } - return client.ListObjects("system_snapshot/") + prefix := "system_snapshot" + if len(backup.BackupPath) != 0 { + prefix = path.Join("/"+strings.TrimPrefix(backup.BackupPath, "/"), prefix) + } + return client.ListObjects(prefix) } func (u *BackupService) NewClient(backup *model.BackupAccount) (cloud_storage.CloudStorageClient, error) { diff --git a/backend/utils/cloud_storage/client/onedrive.go b/backend/utils/cloud_storage/client/onedrive.go index c1f8a877..110ff023 100644 --- a/backend/utils/cloud_storage/client/onedrive.go +++ b/backend/utils/cloud_storage/client/onedrive.go @@ -211,9 +211,6 @@ func (onedrive *oneDriveClient) ListObjects(prefix string) ([]interface{}, error if err := onedrive.client.Do(context.Background(), req, false, &driveItems); err != nil { return nil, fmt.Errorf("do request for list failed, err: %v", err) } - for _, item := range driveItems.DriveItems { - return nil, fmt.Errorf("id: %v, name: %s \n", item.Id, item.Name) - } var itemList []interface{} for _, item := range driveItems.DriveItems {