Community
    • Login

    Notepad++ just deleted all the text from my files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    40 Posts 9 Posters 6.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Alan KilbornA
      Alan Kilborn @Ekopalypse
      last edited by

      @Ekopalypse said:

      how could all files, edited by Npp, from the filesystem get corrupted by this mechanism?

      Well that’s the big question, isn’t it? :)

      EkopalypseE 1 Reply Last reply Reply Quote 2
      • EkopalypseE
        Ekopalypse @Alan Kilborn
        last edited by

        @Alan-Kilborn

        I’m quite good in asking obvious questions :-D

        1 Reply Last reply Reply Quote 1
        • Alan KilbornA
          Alan Kilborn @Ekopalypse
          last edited by

          @Ekopalypse said:

          I do NOT say that OP is lying

          Right. OP is sincere and is not trolling. I’m fairly sure the NUL thing happened to me once a long time ago (before I even knew about this forum) in a minor way (one file that was unimportant got NULlified after a strange crash). I did not recognize it as anything but a curious weirdness at the time. But now I pay attention when someone mentions NUL and does not mean opening a binary file.

          1 Reply Last reply Reply Quote 3
          • rinku singhR
            rinku singh
            last edited by

            NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL

            as about 10 months ago i got same problem but in different condition(while saving there changes to .nova files as request i got admin mode but all open files changes into NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL NUL

            1 Reply Last reply Reply Quote 0
            • pnedevP
              pnedev
              last edited by

              @Ekopalypse ,

              Yes, this issue is really weird. @Alan-Kilborn said it right - only the modified files get corrupted. This is the notorious issue with file corruption on power loss.
              The strange thing is the session file as well. But, again, it is also “modified”. @Maddock-Emerson might have modified it’s theme files as well.
              The difficulty in reproducing this issue makes it very hard to debug so we can basically just guess what might be causing it.

              So here is one guess:
              As far as I recall from the code, if you have edited a file and haven’t saved it and the backup is enabled, and there is power loss for example, after Notepad++ restarts, it detects that the file has backup and restores it from there. I can’t remember if Notepad++ asks the user for confirmation, perhaps it does. But if during the power loss the backup was taking place, the backup might be corrupted BUT the original file might be OK and just AFTER Notepad++ restarts, the corrupted backup overwrites the “unsaved” original file.

              I need to check that scenario.

              Alan KilbornA 1 Reply Last reply Reply Quote 4
              • pnedevP
                pnedev
                last edited by

                @Maddock-Emerson ,

                Do you by any chance still keep the files that are all NUL?
                Can you send some of them to me? You can simply share them here in the community or send them via e-mail (pg.nedev@gmail.com).
                Thank you.

                1 Reply Last reply Reply Quote 1
                • Alan KilbornA
                  Alan Kilborn @pnedev
                  last edited by

                  @pnedev said:

                  Yes, this issue is really weird. @Alan-Kilborn said it right - only the modified files get corrupted.

                  Well, thanks! Sometimes I get it right (still striving for 100%). :)

                  I should have mentioned that (and again going from memory) that at least one user complained that not only are the modified-during-current-run files trashed, but any backups (either of the .bak variety, or the verbose type) made of these files made during the current run are also NULlified. Since these backup files were “modified” (by N++) during the current run, they suffer the same fate as files in tabs (that have been “modified”).

                  So this is a doubly dangerous bug as the normal backup mechanism is providing absolutely zero protection. One could work for hours (or days) on a file, feeling their data is very protected…when in reality nothing could be further from truth.

                  Aside: The word modified has an association when talking about file-tabs in N++ that changes have been made and not saved (i.e., tab floppy disk icon is red). This may be confusing for the current discussion because the corruption very likely affects both types of files (modified-but-unsaved and normal saved files). Maybe for purpose of discussion of this, it is better to talk of files touched by N++ during current N++. (Yes, I know “touch” has another meaning – altering the timestamp of a file without changing its contents – which shouldn’t be confused here).

                  1 Reply Last reply Reply Quote 3
                  • pnedevP
                    pnedev
                    last edited by pnedev

                    Update:
                    The scenario I guessed above is not true. There is another reason for the NUL file corruption on power loss. As can be seen from the thread linked below it might even be totally unrelated to Notepad++ itself.

                    Here is the link to my previous research on the problem and description of the fix I did plus info on the NUL corruption:
                    https://notepad-plus-plus.org/community/topic/13302/fix-corrupted-txt-file-null/67 .

                    To summarize:
                    There have been two separate issues. I have fixed one of them (connected to backup). The other (NUL corruption) is still there and its cause is not clear yet (it might even be unrelated to Notepad++).
                    Here is a link about similar crashes in other applications as well and a description how Recuva can be used to recover your data loss (not guaranteed but worth trying):
                    https://superuser.com/questions/377904/recover-file-corrupted-due-to-power-cut-off

                    1 Reply Last reply Reply Quote 3
                    • pnedevP
                      pnedev
                      last edited by

                      I submitted this PR (https://github.com/notepad-plus-plus/notepad-plus-plus/pull/6164)
                      which fixes the issue with deleting a file, leaving it with zero size on save when there is no free space left on disk (I verified that) and hopefully fixes the NUL file corruption on reboot / power loss (I haven’t verified that because the issue is not easily reproducible).

                      1 Reply Last reply Reply Quote 3
                      • donhoD
                        donho
                        last edited by donho

                        I really don’t think it’s Notepad++ issue.

                        Here’s the similar discussion but for another editor:
                        https://github.com/atom/atom/issues/11406

                        As you might all know, ATOM is web browser based code editor, and their code to write on disk (JavaScript?) has nothing in common with Notepad++.

                        Correct me if I’m wrong, but for me it’s rather an OS issue.

                        pnedevP dinkumoilD 2 Replies Last reply Reply Quote 0
                        • pnedevP
                          pnedev @donho
                          last edited by

                          @donho ,

                          There are actually two issues:

                          1. File is erased when you try to save but you don’t have enough space or the actual write fails for some other reason (Read here https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5664 and here https://community.notepad-plus-plus.org/topic/18358/file-content-vanishing/17). This is fixed by https://github.com/notepad-plus-plus/notepad-plus-plus/pull/6164.

                          2. File is corrupted when there is a sudden power loss (or Windows 10 restarts because of updates: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/6133). This might be an OS issue to some extent but we can certainly do better by immediately flushing the file data to disk on save. This is something the CRT doesn’t do thus it is better to use native Win32 API for file access. This is what I’ve done in https://github.com/notepad-plus-plus/notepad-plus-plus/pull/6164. The same approach should be used for writing settings files and sessions (I haven’t done it yet because I had to modify TinyXML code for that and the change would be too big for the reviewers) and also reading files should use it (just to unify the file access approach).

                          1 Reply Last reply Reply Quote 3
                          • dinkumoilD
                            dinkumoil @donho
                            last edited by dinkumoil

                            @donho said in Notepad++ just deleted all the text from my files:

                            for me it’s rather an OS issue.

                            May be, but that’s no reason to decline fixes that help to overcome these issues.

                            As a developer I frequently have to write code to circumvent bugs caused by otherones code, that’s quite normal. And this issue is a catastrophic one, it should be fixed.

                            1 Reply Last reply Reply Quote 4
                            • Alan KilbornA
                              Alan Kilborn
                              last edited by

                              @donho said in Notepad++ just deleted all the text from my files:

                              but for me it’s rather an OS issue.

                              But…virtually no one will blame the OS. They will blame Notepad++. That’s just the way it is. And a text editor doesn’t need that type (losing data) of reputation.

                              1 Reply Last reply Reply Quote 4
                              • caryptC
                                carypt
                                last edited by carypt

                                as i discovered from working on a file (in npp 7.8.9 or 7.9 32b), saving edits of an opened file under same name (save-as-operation) didnt save (by external editor checked). ( it said to do so , but did not .) shutting npp down and restart npp again did not change on this . buuut, when i closed the file-tab (with out further editing) in npp i was asked if i want to save the changes (should have already been saved !) , then the changes were written to disc(-file) . it seems the save-as worked only with a new filename.

                                this implies a still "hand on file"behaviour of npp , not beeing able to overwrite the existing file-source(-file). it would explain the nul-ing of opened files , because the only valid version of the file seems to be in working memory of npp .

                                i would expect a 1) original-disc-file-version and a 2) working file-version in npp-memory , and a 3) backup-file-version written to backup folder . saving 2) on 1) (overwriting) didnt work , whereas saving 2) on 3) (overwriting) seems good working . saving 2) on 1)(overwriting) works only when closing file-tab when been asked (save file … ? - window pop).

                                to prevent this , open only copies of files in npp , and save work by using a new file name .

                                sry for my so late reply here .

                                Alan KilbornA 1 Reply Last reply Reply Quote 0
                                • caryptC
                                  carypt
                                  last edited by

                                  maybe it needs a fourth 4)disc-copy-file-version for notepad++ to work on , and not on the 1)original-disc-file-version .

                                  1 Reply Last reply Reply Quote 0
                                  • Alan KilbornA
                                    Alan Kilborn @carypt
                                    last edited by

                                    @carypt said in Notepad++ just deleted all the text from my files:

                                    saving edits of an opened file under same name (save-as-operation)

                                    Ok, so WHY would you do this?
                                    Don’t do a “Save As”, just do a “Save”.

                                    I find that if I try this, unintuitive as it may seem, I get this:

                                    3bd8a0bf-9de7-4e77-8ad8-70538adcce60-image.png

                                    If I say “Yes”, I get:

                                    af92493c-7374-4c2c-9122-9acb77552963-image.png

                                    and any edits in my file are not affected (the file is not saved).

                                    So, aside from the fact that you shouldn’t do this, I didn’t see any real harm in it.

                                    1 Reply Last reply Reply Quote 0
                                    • caryptC
                                      carypt
                                      last edited by

                                      hello , i cannot believe , you see no harm in it , that npp isnt able to produce a simple save operation , because it is already opened in npp . “why” should i use the “save as”-command : to absolutely know , what is done and where and under what name in my filesystem . i can follow and control the file operations , it is nailed down to what where and when . i cant see , why a replacement operation is unusual , at least notepad in window is able to perfom it ( must i add aminus to npp ?)

                                      Alan KilbornA 1 Reply Last reply Reply Quote 0
                                      • caryptC
                                        carypt
                                        last edited by

                                        i wouldnt say the nul-effect is caused by the “save as matter” , but it looks suspicious .
                                        what if i make a different thread to it ?

                                        1 Reply Last reply Reply Quote 0
                                        • caryptC
                                          carypt
                                          last edited by carypt

                                          i would at least expect an error message , explicite displaying that the save operation (overwriting) wasnt successful instead of displaying a visibly known fact . or what ? i get no feedback about data loss .

                                          1 Reply Last reply Reply Quote 0
                                          • Alan KilbornA
                                            Alan Kilborn @carypt
                                            last edited by

                                            @carypt said in Notepad++ just deleted all the text from my files:

                                            to absolutely know , what is done and where and under what name in my filesystem

                                            When you have a file open in a tab in Notepad++, you can see where changes to it will be saved by:

                                            • looking at the title bar of N++, where the full path is shown (there is a preference setting to turn this off but it is on by default)

                                            • hovering over the tab with the mouse, at which point a tooltip window will pop up, showing the complete path

                                            REPEAT: There is no need ever to do a Save As on an existing file, unless you intend to create a copy with a different name.

                                            You seem to be a different kind of thinker.

                                            And for other readers: No, @carypt 's postings in this thread are NOT related to the NUL NUL NUL problem in Notepad++.

                                            1 Reply Last reply Reply Quote 3
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors