mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-02-24 23:13:53 +08:00
sync-ui
This commit is contained in:
parent
91891d9798
commit
73a6035167
3 changed files with 14 additions and 9 deletions
|
@ -36,10 +36,11 @@ func InitDB() {
|
||||||
newLogger := logger.New(
|
newLogger := logger.New(
|
||||||
log.New(os.Stdout, "\r\n", log.LstdFlags),
|
log.New(os.Stdout, "\r\n", log.LstdFlags),
|
||||||
logger.Config{
|
logger.Config{
|
||||||
SlowThreshold: time.Second,
|
SlowThreshold: time.Second,
|
||||||
LogLevel: logLevel,
|
LogLevel: logLevel,
|
||||||
ParameterizedQueries: true,
|
ParameterizedQueries: true,
|
||||||
Colorful: true,
|
Colorful: true,
|
||||||
|
IgnoreRecordNotFoundError: true,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,12 @@ func (fs *FileService) CreateFile(c *gin.Context) (*schemas.FileOut, *types.AppE
|
||||||
fileIn.Path = strings.TrimSpace(fileIn.Path)
|
fileIn.Path = strings.TrimSpace(fileIn.Path)
|
||||||
|
|
||||||
if fileIn.Path != "" {
|
if fileIn.Path != "" {
|
||||||
var parent models.File
|
|
||||||
if err := fs.Db.Where("type = ? AND path = ? AND user_id = ?", "folder", fileIn.Path, userId).First(&parent).Error; err != nil {
|
pathId, err := fs.getPathId(fileIn.Path, userId)
|
||||||
return nil, fs.logAndReturn(bindJSONContext, err, http.StatusInternalServerError)
|
if err != nil {
|
||||||
|
return nil, fs.logAndReturn(listFilesContext, err, http.StatusNotFound)
|
||||||
}
|
}
|
||||||
fileDB.ParentID = parent.ID
|
fileDB.ParentID = pathId
|
||||||
}
|
}
|
||||||
|
|
||||||
if fileIn.Type == "folder" {
|
if fileIn.Type == "folder" {
|
||||||
|
@ -583,6 +584,7 @@ func (fs *FileService) GetFileStream(c *gin.Context) {
|
||||||
tgClient, _ := tgc.UserLogin(c, session.Session)
|
tgClient, _ := tgc.UserLogin(c, session.Session)
|
||||||
client, err = fs.worker.UserWorker(tgClient, session.UserId)
|
client, err = fs.worker.UserWorker(tgClient, session.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fs.log.Error("file stream", zap.Error(err))
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -601,6 +603,7 @@ func (fs *FileService) GetFileStream(c *gin.Context) {
|
||||||
client, index, err = fs.worker.Next(file.ChannelID)
|
client, index, err = fs.worker.Next(file.ChannelID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fs.log.Error("file stream", zap.Error(err))
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -613,6 +616,7 @@ func (fs *FileService) GetFileStream(c *gin.Context) {
|
||||||
if r.Method != "HEAD" {
|
if r.Method != "HEAD" {
|
||||||
parts, err := getParts(c, client.Tg, file, channelUser)
|
parts, err := getParts(c, client.Tg, file, channelUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fs.log.Error("file stream", zap.Error(err))
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e02a73d7e96aebd1db9c893b9ce3d5576542d241
|
Subproject commit 377f0bd8c67d35d03ec806a8ab58b0d2bad35a0d
|
Loading…
Reference in a new issue