Feat: list oss files

This commit is contained in:
HFO4
2020-04-28 11:43:32 +08:00
parent 1afc750dae
commit 52c2422be9
3 changed files with 68 additions and 27 deletions

View File

@@ -146,13 +146,18 @@ func (job *ImportTask) Do() {
if parent, ok := pathCache[virtualPath]; ok {
parentFolder = parent
} else {
folder, err := fs.CreateDirectory(context.Background(), virtualPath)
if err != nil {
util.Log().Warning("导入任务无法创建用户目录[%s], %s",
virtualPath, err)
continue
exist, folder := fs.IsPathExist(virtualPath)
if exist {
parentFolder = folder
} else {
folder, err := fs.CreateDirectory(context.Background(), virtualPath)
if err != nil {
util.Log().Warning("导入任务无法创建用户目录[%s], %s",
virtualPath, err)
continue
}
parentFolder = folder
}
parentFolder = folder
}
// 插入文件记录

View File

@@ -142,6 +142,8 @@ func TestImportTask_Do(t *testing.T) {
mock.ExpectCommit()
// 查找父目录,但是不存在
mock.ExpectQuery("SELECT(.+)folders").WillReturnRows(sqlmock.NewRows([]string{"id"}))
// 仍然不存在
mock.ExpectQuery("SELECT(.+)folders").WillReturnRows(sqlmock.NewRows([]string{"id"}))
// 创建文件时查找父目录,仍然不存在
mock.ExpectQuery("SELECT(.+)folders").WillReturnRows(sqlmock.NewRows([]string{"id"}))