mirror of https://github.com/Xhofe/alist
				
				
				
			🎨 Pull away Path
							parent
							
								
									b797f4302c
								
							
						
					
					
						commit
						1a69d80489
					
				|  | @ -8,6 +8,32 @@ import ( | |||
| 	"runtime/debug" | ||||
| ) | ||||
| 
 | ||||
| func Path(driver base.Driver, account *model.Account, path string) (*model.File, []model.File, error) { | ||||
| 	return driver.Path(path, account) | ||||
| } | ||||
| 
 | ||||
| func Files(driver base.Driver, account *model.Account, path string) ([]model.File, error) { | ||||
| 	_, files, err := Path(driver, account, path) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if files == nil { | ||||
| 		return nil, base.ErrNotFolder | ||||
| 	} | ||||
| 	return files, nil | ||||
| } | ||||
| 
 | ||||
| func File(driver base.Driver, account *model.Account, path string) (*model.File, error) { | ||||
| 	file, _, err := Path(driver, account, path) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if file == nil { | ||||
| 		return nil, base.ErrNotFolder | ||||
| 	} | ||||
| 	return file, nil | ||||
| } | ||||
| 
 | ||||
| func MakeDir(driver base.Driver, account *model.Account, path string, clearCache bool) error { | ||||
| 	log.Debugf("mkdir: %s", path) | ||||
| 	err := driver.MakeDir(path, account) | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| package file | ||||
| 
 | ||||
| import ( | ||||
| 	"github.com/Xhofe/alist/drivers/operate" | ||||
| 	"github.com/Xhofe/alist/model" | ||||
| 	"github.com/Xhofe/alist/server/common" | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | @ -30,7 +31,7 @@ func Folder(c *gin.Context) { | |||
| 			common.ErrorResp(c, err, 500) | ||||
| 			return | ||||
| 		} | ||||
| 		file, rawFiles, err := driver.Path(path, account) | ||||
| 		file, rawFiles, err := operate.Path(driver, account, path) | ||||
| 		if err != nil { | ||||
| 			common.ErrorResp(c, err, 500) | ||||
| 			return | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ import ( | |||
| 	"fmt" | ||||
| 	"github.com/Xhofe/alist/conf" | ||||
| 	"github.com/Xhofe/alist/drivers/base" | ||||
| 	"github.com/Xhofe/alist/drivers/operate" | ||||
| 	"github.com/Xhofe/alist/model" | ||||
| 	"github.com/Xhofe/alist/server/common" | ||||
| 	"github.com/Xhofe/alist/utils" | ||||
|  | @ -109,7 +110,7 @@ func Path(c *gin.Context) { | |||
| 		common.ErrorResp(c, err, 500) | ||||
| 		return | ||||
| 	} | ||||
| 	file, files, err := driver.Path(path, account) | ||||
| 	file, files, err := operate.Path(driver, account, path) | ||||
| 	if err != nil { | ||||
| 		common.ErrorResp(c, err, 500) | ||||
| 		return | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ import ( | |||
| 	"fmt" | ||||
| 	"github.com/Xhofe/alist/conf" | ||||
| 	"github.com/Xhofe/alist/drivers/base" | ||||
| 	"github.com/Xhofe/alist/drivers/operate" | ||||
| 	"github.com/Xhofe/alist/server/common" | ||||
| 	"github.com/Xhofe/alist/utils" | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | @ -50,7 +51,7 @@ func Proxy(c *gin.Context) { | |||
| 		return | ||||
| 	} | ||||
| 	// 检查文件
 | ||||
| 	file, err := driver.File(path, account) | ||||
| 	file, err := operate.File(driver, account, path) | ||||
| 	if err != nil { | ||||
| 		common.ErrorResp(c, err, 500) | ||||
| 		return | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ func (fs *FileSystem) File(rawPath string) (*model.File, error) { | |||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return driver.File(path_, account) | ||||
| 	return operate.File(driver, account, path_) | ||||
| } | ||||
| 
 | ||||
| func (fs *FileSystem) Files(ctx context.Context, rawPath string) ([]model.File, error) { | ||||
|  | @ -56,7 +56,7 @@ func (fs *FileSystem) Files(ctx context.Context, rawPath string) ([]model.File, | |||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	files, err := driver.Files(path_, account) | ||||
| 	files, err := operate.Files(driver, account, path_) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 微凉
						微凉