Skip to content

Commit

Permalink
fixed an error condition when the source file creates and access viol…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
asdfjkl committed Nov 30, 2020
1 parent a454c0f commit ca1c269
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
26 changes: 21 additions & 5 deletions yahb/CopyModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ public void doCopy()
{
if (makeCopy)
{
File.Copy(x.sourceFile, x.destFile.driveTimeFilename);
try
{
File.Copy(x.sourceFile, x.destFile.driveTimeFilename);
FileInfo fi_dest = new FileInfo(x.destFile.driveTimeFilename);
bool wasReadOnly = false;
if (fi_dest.IsReadOnly)
Expand All @@ -444,18 +444,34 @@ public void doCopy()
fi_dest.CreationTime = fi_source.CreationTime;
fi_dest.LastWriteTime = fi_source.LastWriteTime;
fi_dest.LastAccessTime = fi_source.LastAccessTime;
if(wasReadOnly)
if (wasReadOnly)
{
fi_dest.IsReadOnly = true;
}
if (cfg.verboseMode)
{
cfg.addToLog(x.sourceFile + ": file copied");
}
}
catch(UnauthorizedAccessException unauthEx)
{
cfg.addToLog("ERR: " + x.sourceFile + ": couldn't change access and creation time of destiation file");
cfg.addToLog("ERR: " + x.sourceFile + ": couldn't access file and/or set creation time of destination file");
}
catch (ArgumentException e)
{
cfg.addToLog("ERR: " + x.sourceFile + ": argument exception");
}
catch (PathTooLongException e)
{
cfg.addToLog("ERR: " + x.sourceFile + ": path too long exception");
}
catch (DirectoryNotFoundException e)
{
cfg.addToLog("ERR: " + x.sourceFile + ": directory not found exception");
}
if (cfg.verboseMode)
catch (FileNotFoundException e)
{
cfg.addToLog(x.sourceFile + ": file copied");
cfg.addToLog("ERR: " + x.sourceFile + ": file not found exception");
}
}
} else
Expand Down
4 changes: 2 additions & 2 deletions yahb/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.5.0")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyVersion("1.0.6.0")]
[assembly: AssemblyFileVersion("1.0.6.0")]

0 comments on commit ca1c269

Please sign in to comment.