1
0

fix(files): use absolute path everywhere

(cherry picked from commit 68636f27da707f3ee87ba0e4f1ff100504486608)
This commit is contained in:
kolaente
2024-09-06 12:55:35 +02:00
parent cca02a3f2e
commit 0b9f3070fd
11 changed files with 45 additions and 31 deletions

View File

@ -77,7 +77,7 @@ func (ta *TaskAttachment) NewAttachment(s *xorm.Session, f io.ReadCloser, realna
ta.CreatedBy, err = GetUserOrLinkShareUser(s, a)
if err != nil {
// remove the uploaded file if adding it to the db fails
if err2 := file.Delete(); err2 != nil {
if err2 := file.Delete(s); err2 != nil {
return err2
}
return err
@ -87,7 +87,7 @@ func (ta *TaskAttachment) NewAttachment(s *xorm.Session, f io.ReadCloser, realna
_, err = s.Insert(ta)
if err != nil {
// remove the uploaded file if adding it to the db fails
if err2 := file.Delete(); err2 != nil {
if err2 := file.Delete(s); err2 != nil {
return err2
}
return err
@ -326,7 +326,7 @@ func (ta *TaskAttachment) Delete(s *xorm.Session, a web.Auth) error {
}
// Delete the underlying file
err = ta.File.Delete()
err = ta.File.Delete(s)
// If the file does not exist, we don't want to error out
if err != nil && files.IsErrFileDoesNotExist(err) {
return nil