This commit is contained in:
divyam234 2023-12-30 20:47:40 +05:30
parent 91891d9798
commit 73a6035167
3 changed files with 14 additions and 9 deletions

View file

@ -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,
},
)

View file

@ -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
}

@ -1 +1 @@
Subproject commit e02a73d7e96aebd1db9c893b9ce3d5576542d241
Subproject commit 377f0bd8c67d35d03ec806a8ab58b0d2bad35a0d