diff --git a/internal/workers/share.go b/internal/workers/share.go index 6324cb3987b..0d079d92fbd 100644 --- a/internal/workers/share.go +++ b/internal/workers/share.go @@ -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" ) @@ -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.