File locking

From FreeMind
Revision as of 07:15, 24 March 2016 by Dan Polansky (talk | contribs) (expand)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

There is an experimental file locking feature, disabled by default. To enable the feature, choose Tools > Preferences > Environment > Files > Experimental File Locking. The feature prevents two users from editing a mind map at the same time, thereby overwriting each other's changes. Available since FreeMind 0.6.5.

Algorithm

  • When opening a mind map, FreeMind creates a lock file unless one already exists.
  • After successful creation of the lock file, FreeMind refreshes the lock file every 4 minutes, by writing the user name and the current time into the lock file.
  • Upon opening a mind map, if a fresh lock file exists, FreeMind opens a warning pop-up window stating which user edits the mind map and opens the mind map as read-only. A lock file is considered fresh if the time written into it is no older than 5 minutes, which is the 4 minutes stated above + 1 minute as a reserve. A read-only mind map can still be edited but cannot be saved and has to be saved-as if the content is to be preserved.
  • Upon opening a mind map, if a stale lock file exists, FreeMind deletes the stale lock file and opens the mind map for writing.
  • On Windows, the lock file is attempted to be made a hidden file.
  • Detail: The lock file name is the name of the mind map prefixed with $~ and suffixed with ~.

Reliability

The feature is experimental. The #Bug reports section below contains a bug report that (a) provides a bug fix, and (b) reports that, after the bug fix, the reporting user is happy with the feature.

Implementation

  • Class MindMapMapModel
    • Nested class LockManager
    • MindMapMapModel.tryToLock(): calls lockManager.tryToLock().
    • MindMapMapModel.destroy(): calls lockManager.releaseLock() and lockManager.releaseTimer().
  • Class Tools, Tools.setHidden().

Bug reports

See also