leading dot and trailing # in lock files

Olivier Tilloy olivier.tilloy at canonical.com
Fri Jul 13 16:47:33 UTC 2018

Thanks Mike for the insights,

My approach of changing the lock filename pattern was indeed naive and
would invalidate the benefits of a cross-applications, cross-versions
lock mechanism.

There's little point in implementing an alternative pattern in cases
where the regular lock file cannot be written, if this isn't
propagated to other office programs and backported to all supported
versions. Would it be possible instead to write the document itself
and warn the user that no lock file could be written? Or does the
absence of a lock file mean that the file can only be opened



On Fri, Jul 13, 2018 at 5:15 AM Kaganski Mike <mikekaganski at hotmail.com> wrote:
> When tweaking lock files naming, please keep in mind why the lock files are used in the first place. One of their goals is telling other programs (it means, other LibreOffice/AOO/OOo instances opening same files from other sessions/boxes) that the file is in use (when OS/FS doesn't provide reliable FS locking), and also some basic information on who/where is using the file (so that it's possible to identify and do something sensible with that).
> Changing a lock file name means that all the other programs (e.g., old LO or AOO) will not be able to detect the lock files. Also, current LO would not be able to detect those legacy lock files, or will need to have more complex code to write/read two lock files.
> I'd say that writing a "safe" lockfile name *after* unsuccessful attempt to create a normal lockfile, *and* making sure that the normal lockfile is absent (so that the failure is not because of already-locked file)... could be ~reasonable (because that would mean that normal lockfile name is unavailable, so legacy soffices would not be able to use usual locking there anyway). But that is not just a "let's change our name for all cases" approach.
> And oh, this will introduce more complexity to our fragile and already too complex locking code... well - that may be worth it; see [1] for another example of situation where certain characters are prohibited and locking fails.
> Thank you for consideration.
> [1] https://bugs.documentfoundation.org/show_bug.cgi?id=115747
> --
> Best regards,
> Mike Kaganski.
> ________________________________
> От: LibreOffice <libreoffice-bounces at lists.freedesktop.org> от имени Olivier Tilloy <olivier.tilloy at canonical.com>
> Отправлено: 13 июля 2018 г. 3:36
> Кому: libreoffice at lists.freedesktop.org
> Тема: leading dot and trailing # in lock files
> Hi all,
> I maintain a snap package for libreoffice¹, and it has been reported
> that document files cannot be saved to $HOME/ ² because of the strict
> confinement rules of snappy, whereby writing hidden files (filename
> starting with a dot) in $HOME is forbidden.
> I looked into the document file lock code, and came up with a simple
> patch that removes the leading dot. So far, so good. It was pointed
> out to me that file managers like Nautilus also consider files with a
> trailing tilde (~) to be hidden, so I updated that patch so that lock
> files are represented like so:
>     $HOME/foobar.odt -> $HOME/foobar.odt.lock~
> I was wondering about the trailing # in the current lock file
> implementation. I dug into the git history, and it's always been there
> as far as I can tell, but I'm not sure why. Can anyone shed some light
> on this?
> Is it safe to replace "#" with ".lock~" (only in the context of the
> snap package, I don't intend to upstream that change unless it's
> deemed sensible) ?
> Cheers,
>  Olivier
> ¹ https://snapcraft.io/libreoffice
> ² https://launchpad.net/bugs/1766192
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/libreoffice

More information about the LibreOffice mailing list