Skip to content

Commit

Permalink
Sharing: Verify that record exists before proceeding with upload #3379
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mayer <michael@photoprism.app>
  • Loading branch information
lastzero committed May 6, 2023
1 parent 1c6fae5 commit 232ec78
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/workers/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/photoprism/photoprism/internal/remote/webdav"
"github.com/photoprism/photoprism/internal/search"
"github.com/photoprism/photoprism/internal/thumb"
"github.com/photoprism/photoprism/pkg/clean"
"github.com/photoprism/photoprism/pkg/fs"
)

Expand Down Expand Up @@ -100,6 +101,16 @@ func (w *Share) Start() (err error) {
return nil
}

// Skip deleted files.
if file.File == nil || file.FileID <= 0 {
log.Warnf("share: %s cannot be uploaded because it has been deleted", clean.Log(file.RemoteName))
file.Status = entity.FileShareError
file.Error = "file not found"
file.Errors++
w.logError(entity.Db().Save(&file).Error)
continue
}

dir := path.Dir(file.RemoteName)

// Ensure remote folder exists.
Expand Down

0 comments on commit 232ec78

Please sign in to comment.