mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-27 18:17:13 +00:00
Fixed: Try to set last write time on files moved to recycle bin
This commit is contained in:
parent
4725f4b2bd
commit
257af8b914
1 changed files with 15 additions and 11 deletions
|
@ -62,11 +62,7 @@ public void DeleteFolder(string path)
|
|||
_diskProvider.FolderSetLastWriteTime(destination, DateTime.UtcNow);
|
||||
foreach (var file in _diskProvider.GetFiles(destination, SearchOption.AllDirectories))
|
||||
{
|
||||
if (OsInfo.IsWindows)
|
||||
{
|
||||
//TODO: Better fix than this for non-Windows?
|
||||
_diskProvider.FileSetLastWriteTime(file, DateTime.UtcNow);
|
||||
}
|
||||
SetLastWriteTime(file, DateTime.UtcNow);
|
||||
}
|
||||
|
||||
_logger.Debug("Folder has been moved to the recycling bin: {0}", destination);
|
||||
|
@ -123,12 +119,8 @@ public void DeleteFile(string path, string subfolder = "")
|
|||
_logger.Error(e, "Unable to move '{0}' to the recycling bin: '{1}'", path, destination);
|
||||
throw;
|
||||
}
|
||||
|
||||
//TODO: Better fix than this for non-Windows?
|
||||
if (OsInfo.IsWindows)
|
||||
{
|
||||
_diskProvider.FileSetLastWriteTime(destination, DateTime.UtcNow);
|
||||
}
|
||||
|
||||
SetLastWriteTime(destination, DateTime.UtcNow);
|
||||
|
||||
_logger.Debug("File has been moved to the recycling bin: {0}", destination);
|
||||
}
|
||||
|
@ -192,6 +184,18 @@ public void Cleanup()
|
|||
_logger.Debug("Recycling Bin has been cleaned up.");
|
||||
}
|
||||
|
||||
private void SetLastWriteTime(string file, DateTime dateTime)
|
||||
{
|
||||
// Swallow any IOException that may be thrown due to "Invalid parameter"
|
||||
try
|
||||
{
|
||||
_diskProvider.FileSetLastWriteTime(file, dateTime);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CleanUpRecycleBinCommand message)
|
||||
{
|
||||
Cleanup();
|
||||
|
|
Loading…
Reference in a new issue