Sharing: Verify that record exists before proceeding with upload #3379

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-05-06 11:27:46 +02:00
parent 1c6fae544c
commit 232ec78c56

View file

@ -15,6 +15,7 @@ import (
"github.com/photoprism/photoprism/internal/remote/webdav" "github.com/photoprism/photoprism/internal/remote/webdav"
"github.com/photoprism/photoprism/internal/search" "github.com/photoprism/photoprism/internal/search"
"github.com/photoprism/photoprism/internal/thumb" "github.com/photoprism/photoprism/internal/thumb"
"github.com/photoprism/photoprism/pkg/clean"
"github.com/photoprism/photoprism/pkg/fs" "github.com/photoprism/photoprism/pkg/fs"
) )
@ -100,6 +101,16 @@ func (w *Share) Start() (err error) {
return nil 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) dir := path.Dir(file.RemoteName)
// Ensure remote folder exists. // Ensure remote folder exists.