Zim

Duplicate notes on changing the case of note title

Bug #1178604 reported by Shivam Sharma on 2013-05-10
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zim
Medium
Unassigned

Bug Description

I had a note inside my zim notebook named "Journal". It had several sub-notes inside it.

I then changed the name of the note to "JOURNAL". After a few days when I opened my notebook and was adding a sub-note into that note, I noticed that there were two notes now: "Journal" and "JOURNAL". I tried to delete "Journal" note. But then it showed some error and voila!!

The "Journal" could not be deleted. All my subnotes in both the notes were erased!! I mean they existed but all that was written inside them was gone. Only the titles of the subnotes were remaining.

Fortunately, I had dropbox backup. Still this would be something you might be interested in.

==Details==
OS : Linux Mint 14 (Nadia) (Ubuntu based OS)
Zim version : 0.57

==Error log==

This is zim 0.57
Python version is sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
Gtk version is (2, 24, 13)
Pygtk version is (2, 24, 0)
Platform is posix
Zim revision is:
  branch: pyzim-trunk
  revision: 600 <email address hidden>
  date: 2012-10-08 21:17:51 +0200

======= Traceback =======
  File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 797, in _action_handler
    method(*arg)
  File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 1678, in delete_page
    self.notebook.trash_page(path, update_links, callback)
  File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1700, in trash_page
    return self._delete_page(path, update_links, callback, trash=True)
  File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1741, in _delete_page
    self.store_page(page)
  File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1352, in store_page
    store.store_page(page)
  File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 104, in store_page
    page._store()
  File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 304, in _store
    lines = self._dump()
  File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 345, in _dump
    raise AssertionError, 'BUG: Can not store a page without content'
AssertionError: BUG: Can not store a page without content

Will have a look at the error. I think what happened is that both
entries in the index pointed to the same page. So index out of sync
rather than really having 2 pages. Probably running "update index"
would have fixed it.

I assume the deleted content could also be restored from your desktop's thrash ?

Regards,

Jaap

On Fri, May 10, 2013 at 12:08 PM, Shivam Sharma <email address hidden> wrote:
> Public bug reported:
>
> I had a note inside my zim notebook named "Journal". It had several sub-
> notes inside it.
>
> I then changed the name of the note to "JOURNAL". After a few days when
> I opened my notebook and was adding a sub-note into that note, I noticed
> that there were two notes now: "Journal" and "JOURNAL". I tried to
> delete "Journal" note. But then it showed some error and voila!!
>
> The "Journal" could not be deleted. All my subnotes in both the notes
> were erased!! I mean they existed but all that was written inside them
> was gone. Only the titles of the subnotes were remaining.
>
> Fortunately, I had dropbox backup. Still this would be something you
> might be interested in.
>
> ==Details==
> OS : Linux Mint 14 (Nadia) (Ubuntu based OS)
> Zim version : 0.57
>
> ==Error log==
>
> This is zim 0.57
> Python version is sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
> Gtk version is (2, 24, 13)
> Pygtk version is (2, 24, 0)
> Platform is posix
> Zim revision is:
> branch: pyzim-trunk
> revision: 600 <email address hidden>
> date: 2012-10-08 21:17:51 +0200
>
> ======= Traceback =======
> File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 797, in _action_handler
> method(*arg)
> File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 1678, in delete_page
> self.notebook.trash_page(path, update_links, callback)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1700, in trash_page
> return self._delete_page(path, update_links, callback, trash=True)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1741, in _delete_page
> self.store_page(page)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1352, in store_page
> store.store_page(page)
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 104, in store_page
> page._store()
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 304, in _store
> lines = self._dump()
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 345, in _dump
> raise AssertionError, 'BUG: Can not store a page without content'
> AssertionError: BUG: Can not store a page without content
>
> ** Affects: zim
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to Zim.
> https://bugs.launchpad.net/bugs/1178604
>
> Title:
> Duplicate notes on changing the case of note title
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zim/+bug/1178604/+subscriptions

K. Bauer (k.bauer) wrote :

I am observing a similiar bug on Windows 7 64bit.

Renaming fails, then there is an extra entry. In my case the renaming changed the text, not just the case of the characters, which is important on Windows (where NTFS supports case sensitive file names but not all APIs).

After the error is raised, backlinks still link to the original page name and accessing that page raises the same error again. Renaming the page to the old name and trying again fixes the problem.

The bug appears randomly every few pages that I rename.

I observed similiar problems in an older version, but there I credited them to file locks on files inside the attachment folder of the renamed page, making renaming of the folder fail. While the cause is probably unrelated, that too broke backlinks.

-------------------------------------------

This is zim 0.60
Python version is sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
Gtk version is (2, 24, 10)
Pygtk version is (2, 24, 0)
Platform is nt
Zim revision is:
  branch: pyzim
  revision: 672 <email address hidden>
  date: 2013-04-30 19:27:20 +0200

======= Traceback =======
  File "zim\gui\__init__.pyo", line 1674, in _wrap_move_page
  File "zim\gui\__init__.pyo", line 1647, in <lambda>
  File "zim\notebook.pyo", line 1648, in rename_page
  File "zim\notebook.pyo", line 1526, in move_page
  File "zim\notebook.pyo", line 1343, in store_page
  File "zim\stores\files.pyo", line 104, in store_page
  File "zim\stores\files.pyo", line 304, in _store
  File "zim\stores\files.pyo", line 345, in _dump
AssertionError: BUG: Can not store a page without content

K. Bauer (k.bauer) wrote :

Little correction: Renaming the page back sometimes work. Sometimes it doesn't and the bug appears again when I try to rename the page again.

K. Bauer (k.bauer) wrote :

Also, updating the index does NOT help. Rather, pages for which neither file nor attachment folder exist, reappear after deleting index.db and doing an "update index" even if they have no backlinks.

It is especially bad, when the page renamed has many subpages, as it gets one hell to fix broken links.

Did updating index fix the problem? I never got to test out this fix, as
suggested by Jaap.

Shivam.
On Jul 15, 2013 9:36 PM, "K. Bauer" <email address hidden> wrote:

> Little correction: Renaming the page back sometimes work. Sometimes it
> doesn't and the bug appears again when I try to rename the page again.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1178604
>
> Title:
> Duplicate notes on changing the case of note title
>
> Status in Zim desktop wiki:
> New
>
> Bug description:
> I had a note inside my zim notebook named "Journal". It had several
> sub-notes inside it.
>
> I then changed the name of the note to "JOURNAL". After a few days
> when I opened my notebook and was adding a sub-note into that note, I
> noticed that there were two notes now: "Journal" and "JOURNAL". I
> tried to delete "Journal" note. But then it showed some error and
> voila!!
>
> The "Journal" could not be deleted. All my subnotes in both the notes
> were erased!! I mean they existed but all that was written inside them
> was gone. Only the titles of the subnotes were remaining.
>
> Fortunately, I had dropbox backup. Still this would be something you
> might be interested in.
>
> ==Details==
> OS : Linux Mint 14 (Nadia) (Ubuntu based OS)
> Zim version : 0.57
>
> ==Error log==
>
> This is zim 0.57
> Python version is sys.version_info(major=2, minor=7, micro=3,
> releaselevel='final', serial=0)
> Gtk version is (2, 24, 13)
> Pygtk version is (2, 24, 0)
> Platform is posix
> Zim revision is:
> branch: pyzim-trunk
> revision: 600
> <email address hidden>
> date: 2012-10-08 21:17:51 +0200
>
> ======= Traceback =======
> File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 797, in
> _action_handler
> method(*arg)
> File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 1678, in
> delete_page
> self.notebook.trash_page(path, update_links, callback)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1700, in
> trash_page
> return self._delete_page(path, update_links, callback, trash=True)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1741, in
> _delete_page
> self.store_page(page)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1352, in
> store_page
> store.store_page(page)
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 104, in
> store_page
> page._store()
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 304, in
> _store
> lines = self._dump()
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 345, in
> _dump
> raise AssertionError, 'BUG: Can not store a page without content'
> AssertionError: BUG: Can not store a page without content
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zim/+bug/1178604/+subscriptions
>

Shivam Sharma (shivams-cool) wrote :
Download full text (3.3 KiB)

This sounds like a very creepy bug. We never know when it may appear.

I'll try to find out the conditions when the bug appears, though the bug
has appeared only once in my case.

I think this bug is a high priority bug. I shudder to think what it may do
when I rename a note with a deep hierarchy of sub-notes in it.
On Jul 15, 2013 9:45 PM, "K. Bauer" <email address hidden> wrote:

> Also, updating the index does NOT help. Rather, pages for which neither
> file nor attachment folder exist, reappear after deleting index.db and
> doing an "update index" even if they have no backlinks.
>
> It is especially bad, when the page renamed has many subpages, as it
> gets one hell to fix broken links.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1178604
>
> Title:
> Duplicate notes on changing the case of note title
>
> Status in Zim desktop wiki:
> New
>
> Bug description:
> I had a note inside my zim notebook named "Journal". It had several
> sub-notes inside it.
>
> I then changed the name of the note to "JOURNAL". After a few days
> when I opened my notebook and was adding a sub-note into that note, I
> noticed that there were two notes now: "Journal" and "JOURNAL". I
> tried to delete "Journal" note. But then it showed some error and
> voila!!
>
> The "Journal" could not be deleted. All my subnotes in both the notes
> were erased!! I mean they existed but all that was written inside them
> was gone. Only the titles of the subnotes were remaining.
>
> Fortunately, I had dropbox backup. Still this would be something you
> might be interested in.
>
> ==Details==
> OS : Linux Mint 14 (Nadia) (Ubuntu based OS)
> Zim version : 0.57
>
> ==Error log==
>
> This is zim 0.57
> Python version is sys.version_info(major=2, minor=7, micro=3,
> releaselevel='final', serial=0)
> Gtk version is (2, 24, 13)
> Pygtk version is (2, 24, 0)
> Platform is posix
> Zim revision is:
> branch: pyzim-trunk
> revision: 600
> <email address hidden>
> date: 2012-10-08 21:17:51 +0200
>
> ======= Traceback =======
> File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 797, in
> _action_handler
> method(*arg)
> File "/usr/lib/pymodules/python2.7/zim/gui/__init__.py", line 1678, in
> delete_page
> self.notebook.trash_page(path, update_links, callback)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1700, in
> trash_page
> return self._delete_page(path, update_links, callback, trash=True)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1741, in
> _delete_page
> self.store_page(page)
> File "/usr/lib/pymodules/python2.7/zim/notebook.py", line 1352, in
> store_page
> store.store_page(page)
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 104, in
> store_page
> page._store()
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 304, in
> _store
> lines = self._dump()
> File "/usr/lib/pymodules/python2.7/zim/stores/files.py", line 345, in
> _dump
> raise AssertionError, '...

Read more...

The rename itself is just renaming a text file and a folder. These operations are atomic on most operating systems, meaning that they can either fail or succeed, but if they fail, the old file / folder is still there - they never fail halfway through.

What can go wrong in zim is that some error happens between the move and the updating of links. Result may be that the index is out of sync, and there are pages still linking to the old name.

Old links will have to be fixed manually. Index can be fixed by a forced update (zim --index).

So I see limited risk. For sure the data will always be still there in the folder, it is just zim view of the data that is messed up.

What I think happened in the original report is that both entries in the index linked to the same folder (due to case (in)sensitivity), deleting what looked as one copy took down both copies.

Will think how to address this particular case by preventing case-duplicates in the index.

Changed in zim:
status: New → Confirmed
importance: Undecided → Medium
tags: added: index
Shivam Sharma (shivams-cool) wrote :

There is a good news!! I finally found what was causing the issue.

This bug re-appeared again when I renamed a note in my notebook and changed its case e.g. Home -> HOME.

The culprit was DROPBOX!! Zim still rocks and there is no bug in Zim that is causing the issue.

What is happening is that after changing the case of the note, the folder and the text file corresponding to that note also change their case. Dropbox has problems with this because OS like Windows don't recognize files with same name but different cases. So, Dropbox renames such files/folders by adding a string to their names : "Case Conflict".

See here: http://askubuntu.com/questions/46658/has-ubuntu-gone-case-insensitive
OR in the official dropbox FAQs: https://www.dropbox.com/en/help/145

So, if anyone is using Dropbox to sync their ZIM notebooks, please be cautious and do not rename your notes by only changing their case.

If you absolutely want to change the case of some of your note, first change it to something else, and then to the old name with case-changed, e.g. Home -> Random -> HOME.

Roman Korcek (roman-korcek) wrote :

Hi all,
I am using the Windows client, version 0.65. The bug is still present. If I rename a page say, from "Travel" to "TRAVEL" it gets duplicated. In my case I renamed eg the subpage "Travel" to "TRAVEL" and then the root page "Home" to "HOME", see attached screenshots and dir structure. The structure is fine on the disk itself but duplicated in Zim. Updating Index does not help. Deleting a duplicate page would delete the page from disk (of which there is only one) so if I did that I would lose both the duplicate and the correct page.

Roman Korcek (roman-korcek) wrote :

I should add that the notebook is saved in a folder that is synchronized to the cloud (but it does not seem it matters if the cloud sync software is active or not). Does Zim perhaps store some data (cache?) outside the "Notes" folder that would get out of sync with the folder when updated from the cloud?

Roman Korcek (roman-korcek) wrote :

Renaming / deleting index.db from C:\Users\korcek\AppData\Local\Microsoft\Windows\Temporary Internet Files\zim\zim\notebook-C_<redacted>_Zim_Notebooks_Notes\ solves the issue.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers