diff --git a/pkg/database/database.go b/pkg/database/database.go index 776d7fe..5fe6ecd 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -36,10 +36,11 @@ func InitDB() { newLogger := logger.New( log.New(os.Stdout, "\r\n", log.LstdFlags), logger.Config{ - SlowThreshold: time.Second, - LogLevel: logLevel, - ParameterizedQueries: true, - Colorful: true, + SlowThreshold: time.Second, + LogLevel: logLevel, + ParameterizedQueries: true, + Colorful: true, + IgnoreRecordNotFoundError: true, }, ) diff --git a/pkg/services/file.go b/pkg/services/file.go index cb7323a..2d347fc 100644 --- a/pkg/services/file.go +++ b/pkg/services/file.go @@ -76,11 +76,12 @@ func (fs *FileService) CreateFile(c *gin.Context) (*schemas.FileOut, *types.AppE fileIn.Path = strings.TrimSpace(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 { - return nil, fs.logAndReturn(bindJSONContext, err, http.StatusInternalServerError) + + pathId, err := fs.getPathId(fileIn.Path, userId) + if err != nil { + return nil, fs.logAndReturn(listFilesContext, err, http.StatusNotFound) } - fileDB.ParentID = parent.ID + fileDB.ParentID = pathId } if fileIn.Type == "folder" { @@ -583,6 +584,7 @@ func (fs *FileService) GetFileStream(c *gin.Context) { tgClient, _ := tgc.UserLogin(c, session.Session) client, err = fs.worker.UserWorker(tgClient, session.UserId) if err != nil { + fs.log.Error("file stream", zap.Error(err)) http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -601,6 +603,7 @@ func (fs *FileService) GetFileStream(c *gin.Context) { client, index, err = fs.worker.Next(file.ChannelID) if err != nil { + fs.log.Error("file stream", zap.Error(err)) http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -613,6 +616,7 @@ func (fs *FileService) GetFileStream(c *gin.Context) { if r.Method != "HEAD" { parts, err := getParts(c, client.Tg, file, channelUser) if err != nil { + fs.log.Error("file stream", zap.Error(err)) http.Error(w, err.Error(), http.StatusInternalServerError) return } diff --git a/ui/teldrive-ui b/ui/teldrive-ui index e02a73d..377f0bd 160000 --- a/ui/teldrive-ui +++ b/ui/teldrive-ui @@ -1 +1 @@ -Subproject commit e02a73d7e96aebd1db9c893b9ce3d5576542d241 +Subproject commit 377f0bd8c67d35d03ec806a8ab58b0d2bad35a0d