Skip to content

Commit c14cdb4

Browse files
committed
Fix thumbnails not moving to the correct place
1 parent 369aa95 commit c14cdb4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

server/organize.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,13 @@ func (srcAlbum *Album) MovePhotos(mode string, srcCollection *Collection, dstCol
351351
// Move thumbnail
352352
srcThumbPath := photo.src.ThumbnailPath(srcCollection)
353353
dstThumbPath := photo.dst.ThumbnailPath(dstCollection)
354-
err := os.Rename(srcThumbPath, dstThumbPath)
355-
if err != nil { // If not possible to rename, remove thumbnail for cleanup
356-
os.Remove(srcThumbPath)
354+
// Ensure the directories exist
355+
if err := os.MkdirAll(filepath.Dir(dstThumbPath), os.ModePerm); err == nil {
356+
err := os.Rename(srcThumbPath, dstThumbPath)
357+
if err != nil { // If not possible to rename, remove thumbnail for cleanup
358+
os.Remove(srcThumbPath)
359+
}
357360
}
358-
359361
// Move photo info
360362
srcCollection.cache.DeletePhotoInfo(photo.src)
361363
dstCollection.cache.AddPhotoInfo(photo.dst)

0 commit comments

Comments
 (0)