Skip to content

Commit

Permalink
sync-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
divyam234 committed Dec 30, 2023
1 parent 91891d9 commit 73a6035
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
9 changes: 5 additions & 4 deletions pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)

Expand Down
12 changes: 8 additions & 4 deletions pkg/services/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion ui/teldrive-ui

0 comments on commit 73a6035

Please sign in to comment.