Bug 82744 - WebDAV LOCK is released when document is saved
Summary: WebDAV LOCK is released when document is saved
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.3.0.4 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard: target:5.1.0
Keywords:
Depends on:
Blocks: 83531
  Show dependency treegraph
 
Reported: 2014-08-18 06:01 UTC by it
Modified: 2016-10-25 19:17 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description it 2014-08-18 06:01:51 UTC
This is an aftereffect of Bug #72157:



Problem:
When a document is opened via WebDAV and saved (not closed), then LibreOffice releases mistakenly the LOCK. This must only happen, when the document is closed and not just saved.



Steps to reproduce:
1. Open a document via WebDAV (GET + LOCK is send to the webserver)
2. Save the document on WebDAV (UNLOCK + PUT is send to the webserver)
3. Close the document (nothing is send to the webserver)



Affected versions:
- 4.2.6.2 (release)
- 4.3.0.4 (release)



Additional comments:
In Bug #72157 comment 28 and later some other people already confirmed this problem. Samuel Mehrbrodt told to create a new bug report about this issue.
Comment 1 it 2015-03-06 14:21:02 UTC
This problem still exists in 4.4.1.2.
Comment 2 Chris Laplante 2015-04-21 17:14:38 UTC
I did a little digging into this bug, and it seems the problem is caused by the destructor of Content (webdavcontent.cxx) assuming it is OK to unlock the document. When saving (but not closing), the Content object is destroyed and recreated, thereby unlocking the document on the server. Of course, in this instance the unlock never should have been sent.

I found the original(?) bug from Open Office which discusses the problem a little more: https://bz.apache.org/ooo/show_bug.cgi?id=29152. It seems the original developers who considered this issue recommended an explicit lock/unlock strategy: https://bz.apache.org/ooo/show_bug.cgi?id=29152#c113. Quoting: "The OOo document load/save framework is the right place to decide whether a
lock is needed for the document resource. All needed context is available there."

Currently we're using an implicit approach, where the Content object in the UCB decides when to lock/unlock based on when it is created and destroyed. I'm no LO expert, but the UCB seems too low of a level in the framework to make the right decision.

I see that the webdavcontent.cxx::Content class supports the "lock" and "unlock" command through Content::execute(). Maybe we could execute("lock") on document open from the load/save framework, and similarly execute("unlock") on document close. Is this a reasonable approach? If so, my next task is to find the correct place to implement these calls.

FWIW, I looked at how the OneDrive/SharePoint checkin and checkout works (since the concepts are similar to lock/unlock). Unfortunately it wasn't much help, since in those cases the user manually checks documents in and out, whereas here we want it to happen automatically.
Comment 3 Giuseppe Castagno (aka beppec56) 2015-07-13 09:21:51 UTC
I recently added the WebDAV lock/unlock mechanism in AOO.

https://bz.apache.org/ooo/show_bug.cgi?id=126305

it's scheduled to be included in 4.1.2.

In AOO the lower WebDAV layer is managed by serf, not by neon, the work there was a little different, but I implemented the framework strategy for lock/unlock.

If I'm assigned this bug, I'll do the rewriting for LibO for the framework part.
Comment 4 Samuel Mehrbrodt (CIB) 2015-07-13 09:59:30 UTC
> If I'm assigned this bug, I'll do the rewriting for LibO for the framework part.

Your work would be very welcome - please go ahead :)
Comment 5 Giuseppe Castagno (aka beppec56) 2015-07-13 10:22:19 UTC
(In reply to Samuel Mehrbrodt from comment #4)

Ok, work in progress.
Comment 6 Commit Notification 2015-07-22 15:50:58 UTC
Giuseppe Castagno committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=26e6d4b05ab444e6a7529ffcac7fbe592fc94833

tdf#82744: fix WebDAV lock/unlock behaviour - part 1

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2015-07-22 16:18:29 UTC
Giuseppe Castagno committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=bc9a8ddbb7081f79e915c841e56fd1c40f0df6f9

tdf#82744: fix WebDAV lock/unlock behaviour - part 2

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Giuseppe Castagno (aka beppec56) 2015-07-22 18:03:20 UTC
For the sake of clarity, the two commits above are not the only needed.

There is one that has not been pushed yet.

I'll post a note as soon as all the patches implementing the issue fix are pushed to master.
Comment 9 Commit Notification 2015-08-14 13:38:16 UTC
Giuseppe Castagno committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=fed2984281a85a5a2f308841ec810f218c75f2ab

tdf#82744: fix WebDAV lock/unlock behaviour - part 4

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2015-10-05 11:15:53 UTC
Giuseppe Castagno committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b4576f3da4d90139fc5140962d13cb91dab98797

tdf#82744: fix WebDAV lock/unlock behaviour - part 3

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 11 Giuseppe Castagno (aka beppec56) 2015-10-12 09:44:02 UTC
The daily builds contain the changes related to this issue starting with date Oct, 6th.
As of today Linux, Windows  and Mac builds are available.

As soon as someone has spare time, can he/she try it?

Thanks.
Comment 12 Mike Kaganski 2016-07-24 09:25:52 UTC
@Giuseppe: see https://freedomsponsors.org/issue/509/libreoffice-does-not-release-webdav-file-lock-on-document-close
This bug is being sponsored, so it would be fair if you informed them on your fixing this and claimed your part of bounty