Notepad++ has a Reload false alarm / bug? "This file has been modified by another program. Do you want to reload it"? even when it hadn't been recently modified at all?!
-
Had a weird incident recently where I had multiple text (.txt) based documents that I had written myself (basically notes, reminders, scratchpad stuff) and I’m using notepad++ and with multiple tabs open. I don’t have the MS notepad open nor do I have any other editor application (such as Word etc) open/running. I only have one instance of (multi-tabbed) notepad++ open. No other applications should have been making changes to any of my text files that I had opened in notepad++.
I was doing something in the web browser and switched to the notepad++ application, suddenly I get the prompt about “Reload – This file has been modified by another program. Do you want to reload it?” and out of habit/instinct I just clicked on “Yes” to get the nag dialog box out of the way, hoping then I could tab over to the text file that I had been using as a pastebin for my copy/paste clipboard of things I was copying from the firefox/chrome browser…
Immediately I’m presented with another such prompt, asking me the exact same question about if I wished to Reload this new tab/ additional text file, that is when I got a bit suspicious since I new for sure I hadn’t been updating two different text files… so I took a screenshot with greenshot of it… then to my surprise after this time clicking that No I didn’t wish to reload, I’m prompted a THIRD time about if I want to reload yet ANOTHER tab/instance/textfile! I also click No…
Afterwards since each time it shows the exact path of the text file in question that is asking about reload, I go to the path on the Windows Explore (I’m using Windows 10) and right click each of the text files to check the Created, Modified, Accessed etc and they were from back in late October!
These text files are in a directory that is sync’d by MEGA (sort of like dropbox) with revisions, so I log into my MEGA account and check the revision histories to see what is going on… Then I download a couple of prior revisions and confirmed that indeed the data looks good, no sign of data corruption or somehow a revision accidentally reverting by mistake, and indeed the MEGA revision confirmed what Windows Explorer confirmed, and that is there hadn’t been any changes since October to the files…
I used WinMerge to compare the diff of revisions compared to current file and see that I had only been adding content over time, not deleting/revision, so nothing out of the ordinary… Indeed the October timestamp is the final one…
Yet, I reboot my machine each night, and my computer hadn’t been up for more than 12 hours from the last reboot, I don’t do sleep or hibernation, so there is no way I could have had this notepad++ instance open for more than a few hours… this is on my host machine not a VM, so its not like I could have reverted to a prior snapshot by mistake etc… The tabs that I had open weren’t edited/modified since October, and yet tonight for some strange reason I got prompted by Notepad++ stating that these files have been changed and asking me if I wish to reload?
My question is there a bug with Notepad++ that could be doing this false alarm/alert or is it that my computer is compromised somehow and files are changing behind the scenes without me being aware?
-
@bo-chen
I’m going to go out on a limb here, as I note that this is your second post concerning MEGA and Notepad++.AFAIK Notepad++ is designed around static storage, as in hard drives and SSDs. When a user decides to use network storage, whether it’s a corporate server, a NAS box or a cloud service, e.g., MEGA, they have started down the slippery slope of active version management. Notepad++ will detect a file modified ‘behind the users back’ and offer to reload it or ignore the changes. Trying to do more is outside the scope of Notepad++. My guess is that the developers do not offer more choices (e.g., save a copy somewhere else and then reload the contents) to avoid potential data integrity issues best left to the operating system (which at this point appears to have broken the implicit promise of static storage).
My guess is that you have somehow configured MEGA to do more than automatically preserve file contents. If that is the case, I’d then say Notepad++ is trying to cope with a system where file contents have changed and is now trying to alert you to that. The alert will be on a per file (active tab) basis when you (re)activate a tab. So far everything sounds normal to me. The how and why the MEGA presented file contents changed (or didn’t change) is outside the purview of this community. It’s also possible that MEGA is having issues, but that is not something Notepad++ can ever solve.
-
Yep, I agree with @artie-finkelstein . Some time ago I posted about this sort of thing with files on a Microsoft “OneDrive”. I never really came up with a satisfactory solution so I just don’t edit files on this drive with Notepad++ (if I can avoid doing it).
-
Hi,
I want to upvote this thread because I installed new version of npp today and since this new update (version 8.1.9, 64-bit) I got “file has changed” notification.The files are stored on a windows network drive and there was no problem with this mechanism this in the previous versions.
It is reproduceable by changing a file, save the file, switch to another program (e.g. explorer) switch back to npp and the message appears.So it seems there was a change in detecting the modification of a file (maybe time resolution to recognize a modified file or something else was changed)?
thank you!
Leo -
@bo-chen
What’s your Notepad++ version? -
It is reproduceable by changing a file, save the file, switch to another program (e.g. explorer) switch back to npp and the message appears.
Is it reproducible 100% for you?
What’s the version before you updated your Notepad++ to v8.1.9?
I have tried with files on oneDrive, but cannot reproduce it. Any idea to build a windows network drive for reproducing this issue? -
@leo-eibler i am upvoting this. my files are saved on a NAS and am experiencing this as well.
-
@leo-eibler i am upvoting this. my files are saved on a NAS and am experiencing this as well.
It’s good for upvoting.
It’s better to let us know your Notepad++ version, so we can identify better the problem and fix this bug. -
@Bo-Chen @Dennis-Lazo @Leo-Eibler
I have no network drive/NAS/MEGA so I can’t reproduce this issue.
However, I find some incoherent code of timestamp detection and did a blend fix:
http://download.notepad-plus-plus.org/repository/MISC/Could you guys test the fixed binary (download above) and confirm me if it work (and the message you see) please?
-
@donho Thank you very much for this fast fix. I installed your fixed version now and will see if it solves the problem.
I tried to find out the version I used before but I was not able to find it - if you have any idea how to find out the previous used version I will tell you ;-)
-
@donho happened again with new Version.
Dialog message: “File on disk timestamp is earlier than current buffer timestamp: #2”
And if I click on OK, a second dialog box with same message appears.
If I switch to another program and switch back to npp a 3rd dialog box appears with same message.
Dialog boxes can not be closed - after clicking on OK it appears again and again.So I have to kill the process.
-
@leo-eibler
Could you try the new fix please?
It should be fine now:
http://download.notepad-plus-plus.org/repository/MISC/NewFix/ -
@donho Is it possible that you don’t fixed the x64 version? because it has older date (2021-11-12 04:02 2.3M) and other filename (missing the word “new”)
-
@donho Is it possible that you don’t fixed the x64 version? because it has older date (2021-11-12 04:02 2.3M) and other filename (missing the word “new”)
You are right. Fixed now.
-
@donho thank you very much. I will test it.
-
@donho it looks very good … I tested it now (for the last 2 hours) and no “file has been modified” dialog any more ;-)
I also tested to modify the file really outside the editor and this works also - the modified dialog appears as expected.
I keep on testing next week but I think you solved the bug ;-)
Thank you very very much for your really fast help!BR
-
@donho Out of curiosity, I looked at the code in FileInterface.cpp
In line 25, we have:attrib = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_POSIX_SEMANTICS;
The MSDN documentation for CreateFile says about FILE_ATTRIBUTE_NORMAL:
“This attribute is valid only if used alone.”
In reality, ORing with other attributes may make no real difference. But after coding for some 50 years, I believe being pedantic = good plan :-)
-
@david-johnstone should say Line 125
-
The MSDN documentation for CreateFile says about FILE_ATTRIBUTE_NORMAL:
“This attribute is valid only if used alone.”
In reality, ORing with other attributes may make no real difference. But after coding for some 50 years, I believe being pedantic = good plan :-)You’ve got a point here.
OTOH, the another parameter
FILE_FLAG_POSIX_SEMANTICS
, MS Doc says:FILE_FLAG_POSIX_SEMANTICS 0x01000000 Access will occur according to POSIX rules. This includes allowing multiple files with names, differing only in case, for file systems that support that naming.
We do not need this ability, so I think it can be removed. What do you think @pnedev ?
-
The MSDN documentation for CreateFile says about FILE_ATTRIBUTE_NORMAL:
“This attribute is valid only if used alone.”The thing is, even
FILE_FLAG_POSIX_SEMANTICS
is removed:void Win32_IO_File::fillCreateParams(DWORD &access, DWORD &share, DWORD &disp, DWORD &attrib) { access = GENERIC_READ; share = FILE_SHARE_READ; attrib = FILE_ATTRIBUTE_NORMAL; // Distinguish between upper/lower case in name if (_hMode == Mode::READ) { disp = OPEN_EXISTING; // Open only if file exists and is not locked by other process attrib |= FILE_FLAG_SEQUENTIAL_SCAN; // Optimize caching for sequential read } else { disp = OPEN_ALWAYS; // Open existing file for writing without destroying it or create new access |= GENERIC_WRITE; attrib |= FILE_FLAG_WRITE_THROUGH; // Write cached data directly to disk (no lazy writer) } }
We add always
FILE_FLAG_WRITE_THROUGH
(Mode::READ
is not used in Notepad++ code).@pnedev
What’s your thought?