Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snaketail causing certain lock on text file preventing continuation of log file - not read only #134

Open
jwroosch opened this issue Jul 15, 2019 · 4 comments

Comments

@jwroosch
Copy link

jwroosch commented Jul 15, 2019

Reporting this just in case someone else experiencing something similar strange behavior, possibly involving snaketail.
We're having 2 environments here:
A:

  • the log file is in a folder with underscore(s) in the folder name
  • the program files developed in Visual Studio 2010 and C
    B:
  • the log file is in a folder with dots(s) in the folder name
  • the program files developed in Visual Studio 2017 and C#

In environment A: all works fine
In environment B: when viewing the log file in snaketail, the log file stops working as if locked.
But the file still can be deleted, so not a real lock but to a certain degree, preventing the program from adding anymore lines to the log file.
When closing the view, the log starts functioning again, new lines being added as expected.
What could cause this, the dot(s) in the folder name, or ..
Could it be reproduced? Could it be solved? (So snaketail only monitors files in a read only manner)
Cheers.

@jwroosch jwroosch changed the title snaketail causing certain lock on text file preventing continuation of log file snaketail causing certain lock on text file preventing continuation of log file - not read only Jul 15, 2019
@snakefoot
Copy link
Owner

Pull-Requests are welcome to make the file-monitor even better.

Version 1.9.6 have been released, that introduces the keyboard shortcut CTRL + R

@jwroosch
Copy link
Author

Hi, thanks for the heads up, i tested it with 1.9.6 but regarding this issue seems unchanged.
So unfortunately not solved (yet). Best regards

@snakefoot
Copy link
Owner

snakefoot commented Oct 21, 2019 via email

@ColinNg
Copy link

ColinNg commented Jun 18, 2020

I was not able to fix this, but for anyone looking: I think there are more kinds of shareable file locks in Windows than covered under the docs at https://docs.microsoft.com/en-us/dotnet/api/system.io.fileshare?view=netcore-3.1

The file access is happening in
snaketail-net\SnakeTail\LogFileStream.cs > LoadFile(...) line 317:

_fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete, 65536, FileOptions.SequentialScan);

The FileShare specified is correct. However, PowerShell's Set-Content will complain with:

Set-Content : The process cannot access the file ... because it is being used by another process.

when I call it like: Set-Content 'path\to\file.log' -Value $null
so I replaced that with $null | out-file "path\to\file.log" instead.

However, I cannot always use out-file because a different program writes log files that out-file (and Sublime Text) cannot overwrite, but that Set-Content can.

It is strange but I have to mix both Set-Content and out-file to clear out log files. Thought I would point this out in case somebody accuses this issue of not being reproducible. The Windows flags do not work as documented!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants