ShokoAnime / ShokoServer

Repository for Shoko Server.
http://shokoanime.com/shoko-server/
MIT License
386 stars 75 forks source link

Fix: Ensures temp image moves to valid location #1034

Closed fearnlj01 closed 1 year ago

fearnlj01 commented 1 year ago

Naive fix, but should prevent trace logs like the below from occurring.


[2023-01-16 20:40:56:434] Warn|CommandProcessorImages.WorkerCommands_DoWork => CommandRequestImplementation.ProcessCommand => CommandRequest_DownloadImage.Process Error processing CommandRequest_DownloadImage: https://artworks.thetvdb.com/banners/seasons/5cf5825ace9b9.jpg (62) - System.IO.DirectoryNotFoundException: Could not find a part of the path.
   at System.IO.FileSystem.MoveFile(String sourceFullPath, String destFullPath, Boolean overwrite)
   at System.IO.File.Move(String sourceFileName, String destFileName, Boolean overwrite)
   at System.IO.File.Move(String sourceFileName, String destFileName)
   at Shoko.Server.ImageDownload.ImageDownloadRequest.RecursivelyRetryDownload(Int32 count, Int32 maxRetries) in D:\a\ShokoServer\ShokoServer\Shoko.Server\ImageDownload\ImageDownloadRequest.cs:line 120
   at Shoko.Server.ImageDownload.ImageDownloadRequest.DownloadNow(Int32 maxRetries) in D:\a\ShokoServer\ShokoServer\Shoko.Server\ImageDownload\ImageDownloadRequest.cs:line 65
   at Shoko.Server.Commands.CommandRequest_DownloadImage.Process() in D:\a\ShokoServer\ShokoServer\Shoko.Server\Commands\Import\CommandRequest_DownloadImage.cs:line 198```
fearnlj01 commented 1 year ago

Should've double checked before PR'ing, looks like it was just a case of the temp path being checked for this purpose rather than the file path.

da3dsoul commented 1 year ago

Oh fair. The comment I made was that using FileInfo actually reads the file system, while the other method uses string manipulation to build the path, then only accesses the fs to verify the directory exists/make it