Skip to content

Commit

Permalink
Missed a spot
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Nov 20, 2023
1 parent af71797 commit 9c5c921
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ private long CanAccessFile(string fileName, ref Exception e)
var accessType = Options.FileAccessMode;
try
{
using var fs = File.Open(fileName, FileMode.Open, accessType, FileShare.ReadWrite);
var size = fs.Seek(0, SeekOrigin.End);
return size;
return GetFileSize(fileName, accessType);
}
catch (IOException)
{
Expand All @@ -377,7 +375,7 @@ private long CanAccessFile(string fileName, ref Exception e)
if (info.IsReadOnly) info.IsReadOnly = false;

// check to see if it stuck. On linux, we can't just WinAPI hack our way out, so don't recurse in that case, anyway
if (!new FileInfo(fileName).IsReadOnly && !Utils.IsRunningOnLinuxOrMac()) return CanAccessFile(fileName, ref e);
if (!new FileInfo(fileName).IsReadOnly && !Utils.IsRunningOnLinuxOrMac()) return GetFileSize(fileName, accessType);
}
catch
{
Expand All @@ -389,6 +387,13 @@ private long CanAccessFile(string fileName, ref Exception e)
}
}

private static long GetFileSize(string fileName, FileAccess accessType)
{
using var fs = File.Open(fileName, FileMode.Open, accessType, FileShare.ReadWrite);
var size = fs.Seek(0, SeekOrigin.End);
return size;
}

//Used to check if file has been modified within the last X seconds.
private bool FileModified(string fileName, int seconds, ref long lastFileSize, ref Exception e)
{
Expand Down

0 comments on commit 9c5c921

Please sign in to comment.