mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
Fixed LastWriteTime
This commit is contained in:
parent
82d4933152
commit
88afc19716
@ -39,7 +39,7 @@ public interface IDiskProvider
|
||||
string GetPathRoot(string path);
|
||||
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
|
||||
bool IsParent(string parentPath, string childPath);
|
||||
void SetFolderAccessTime(string path, DateTime time){
|
||||
void SetFolderWriteTime(string path, DateTime time);
|
||||
FileAttributes GetFileAttributes(string path);
|
||||
void EmptyFolder(string path);
|
||||
}
|
||||
@ -442,6 +442,10 @@ public bool IsParent(string parentPath, string childPath)
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetFolderWriteTime(string path, DateTime time)
|
||||
{
|
||||
Directory.SetLastWriteTimeUtc(path, time);
|
||||
}
|
||||
|
||||
private static void RemoveReadOnly(string path)
|
||||
{
|
||||
@ -452,10 +456,6 @@ private static void RemoveReadOnly(string path)
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFolderAccessTime(string path, DateTime time){
|
||||
Directory.SetLastWriteTimeUtc(path,time);
|
||||
}
|
||||
|
||||
public FileAttributes GetFileAttributes(string path)
|
||||
{
|
||||
return File.GetAttributes(path);
|
||||
|
@ -42,9 +42,7 @@ public string MoveEpisodeFile(EpisodeFile episodeFile, Series series)
|
||||
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
||||
var newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile);
|
||||
var filePath = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||
MoveFile(episodeFile, filePath);
|
||||
_diskProvider.SetFolderAccessTime( Path.GetDirectoryName(filePath), episodeFile.DateAdded);
|
||||
_diskProvider.SetFolderAccessTime( series.Path, episodeFile.DateAdded);
|
||||
MoveFile(episodeFile, series, filePath);
|
||||
|
||||
return filePath;
|
||||
}
|
||||
@ -53,14 +51,12 @@ public string MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode
|
||||
{
|
||||
var newFileName = _buildFileNames.BuildFilename(localEpisode.Episodes, localEpisode.Series, episodeFile);
|
||||
var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||
MoveFile(episodeFile, filePath);
|
||||
_diskProvider.SetFolderAccessTime( Path.GetDirectoryName(filePath), episodeFile.DateAdded);
|
||||
_diskProvider.SetFolderAccessTime( localEpisode.Series.Path, episodeFile.DateAdded);
|
||||
|
||||
MoveFile(episodeFile, localEpisode.Series, filePath);
|
||||
|
||||
return filePath;
|
||||
}
|
||||
|
||||
private void MoveFile(EpisodeFile episodeFile, string destinationFilename)
|
||||
private void MoveFile(EpisodeFile episodeFile, Series series, string destinationFilename)
|
||||
{
|
||||
if (!_diskProvider.FileExists(episodeFile.Path))
|
||||
{
|
||||
@ -77,6 +73,17 @@ private void MoveFile(EpisodeFile episodeFile, string destinationFilename)
|
||||
_logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, destinationFilename);
|
||||
_diskProvider.MoveFile(episodeFile.Path, destinationFilename);
|
||||
|
||||
_logger.Trace("Setting last write time on series folder: {0}", series.Path);
|
||||
_diskProvider.SetFolderWriteTime(series.Path, episodeFile.DateAdded);
|
||||
|
||||
if (series.SeasonFolder)
|
||||
{
|
||||
var seasonFolder = Path.GetDirectoryName(episodeFile.Path);
|
||||
|
||||
_logger.Trace("Setting last write time on season folder: {0}", seasonFolder);
|
||||
_diskProvider.SetFolderWriteTime(seasonFolder, episodeFile.DateAdded);
|
||||
}
|
||||
|
||||
//Wrapped in Try/Catch to prevent this from causing issues with remote NAS boxes, the move worked, which is more important.
|
||||
try
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user