You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package model
import (
"github.com/HFO4/cloudreve/pkg/util"
"github.com/jinzhu/gorm"
)
// File 文件
type File struct {
// 表字段
gorm . Model
Name string
SourceName string
UserID uint
Size uint64
PicInfo string
FolderID uint
PolicyID uint
Dir string ` gorm:"size:65536" `
}
// Create 创建文件记录
func ( file * File ) Create ( ) ( uint , error ) {
if err := DB . Create ( file ) . Error ; err != nil {
util . Log ( ) . Warning ( "无法插入文件记录, %s" , err )
return 0 , err
}
return file . ID , nil
}
// GetFileByPathAndName 给定路径、文件名、用户ID, 查找文件
func GetFileByPathAndName ( path string , name string , uid uint ) ( File , error ) {
var file File
result := DB . Where ( "user_id = ? AND dir = ? AND name=?" , uid , path , name ) . Find ( & file )
return file , result . Error
}