WebDav plugin to show file locks

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

WebDav plugin to show file locks

Post by *szlori »

Is it possible to enhance the plug-in to show active file locks?
Perhaps this could be added to the Properties dialog for the file (Version information).

With TC I can't see if a file is locked, whereas bitkinex will show the active locks on the file.

Cheers!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Currently my plugin doesn't support its own properties dialog, but it would certainly be a good idea to add it. Do you have any ideas how the lock is reported? I looked in the DAV*.tmp file in the TEMP directory and found something like this (GMX):

Code: Select all

<D:supportedlock>
<D:lockentry>
<D:lockscope><D:exclusive/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope><D:shared/></D:lockscope>
<D:locktype><D:write/></D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:resourcetype/>
How does it look for you when the file is locked?
Author of Total Commander
https://www.ghisler.com
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

Thanks for the attention! :)

Here is what I see:

Code: Select all

<D:response>
    <D:href>/ushare/webdav/****/Global_FrontEnd_2011.xlsm</D:href>
    <D:propstat>
      <D:prop>
        <D:lockdiscovery>
          <D:activelock>
            <D:locktype>
              <D:write/></D:locktype>
            <D:lockscope>
              <D:exclusive/></D:lockscope>
            <D:depth>0</D:depth>
            <D:owner>cgrenier</D:owner>
            <D:timeout>Infinite</D:timeout>
            <D:locktoken>
              <D:href>opaquelocktoken:4d72a1a6-55ab-4301-a718-527772ed42f3:cgrenier</D:href>
            </D:locktoken>
          </D:activelock>
        </D:lockdiscovery>
        <D:supportedlock>
          <D:lockscope>
            <D:exclusive/></D:lockscope>
          <D:locktype>
            <D:write/></D:locktype>
        </D:supportedlock>
        <D:resourcetype></D:resourcetype>
        <D:displayname>Global_FrontEnd_2011.xlsm</D:displayname>
        <D:source/>
        <D:creationdate>2011-01-19T17:27:41Z</D:creationdate>
        <D:getlastmodified>Tue, 22 Feb 2011 07:15:19 GMT</D:getlastmodified>
        <D:getcontentlanguage></D:getcontentlanguage>
        <D:getcontenttype>application/octet-stream</D:getcontenttype>
        <D:getetag>4d72a1a6-55ab-4301-a718-527772ed42f3_1298358919607</D:getetag>
        <D:getcontentlength>283490</D:getcontentlength>
        <D:authticket>TICKET_1d19027248ed4d36906d9919b3d45cae8aa66a25</D:authticket>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
What bitkinex displays under Active Lock(s) is the <D:locktoken>:
Lock identifier: opaquelocktoken:4d72a1a6-55ab-4301-a718-527772ed42f3:cgrenier
So it seems that you get all the info necessary to find the lock. :)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks for the info! If I understand you correctly, the file is locked when there is an entry "locktoken", is this correct? How does a file entry look when it isn't locked?
Author of Total Commander
https://www.ghisler.com
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

In fact, when there are no locks, this whole section will disappear:

Code: Select all

        <D:lockdiscovery>
          <D:activelock>
            <D:locktype>
              <D:write/></D:locktype>
            <D:lockscope>
              <D:exclusive/></D:lockscope>
            <D:depth>0</D:depth>
            <D:owner>cgrenier</D:owner>
            <D:timeout>Infinite</D:timeout>
            <D:locktoken>
              <D:href>opaquelocktoken:4d72a1a6-55ab-4301-a718-527772ed42f3:cgrenier</D:href>
            </D:locktoken>
          </D:activelock>
        </D:lockdiscovery>
So I would say it is the <D:activelock> element that represents the lock, while the locktoken is just one information about the lock.
You can see other info such as locktype, lockscope and owner as well.

It seems you can have multiple locks on a file (although I guess they shouldn't be "exclusive" in that case, as the above one), but I'm not sure our UShare client supports that - I didn't have much time to play with that. Bitkinex, as well, can just create this kind of lock.

In TC we have no visual clue about this lock, it just looks the same - until the write operation fails on it. :wink:
Bitkinex displays a STOP mark overlay on the file icon and one can check the active locks in the properties dialog.
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

It seems you can have multiple locks on a file (although I guess they shouldn't be "exclusive" in that case, as the above one), but I'm not sure our UShare client supports that - I didn't have much time to play with that. Bitkinex, as well, can just create this kind of lock.
Actually, if I think a bit, I would say that this section:

Code: Select all

        <D:supportedlock>
          <D:lockscope>
            <D:exclusive/></D:lockscope>
          <D:locktype>
            <D:write/></D:locktype>
        </D:supportedlock>
tells you the supported locks.
So in my case this is the only type of lock - exclusive-write lock - that is supported.
Which might explain why I'm able to create only this kind of lock. :)
Am I right?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, sounds reasonable. I will try to add an about box with the locking information.
Author of Total Commander
https://www.ghisler.com
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

Sounds great, cheers!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You can get a first beta version here:
https://plugins.ghisler.com/beta/webdav_21_beta1.zip
Sources:
https://plugins.ghisler.com/beta/webdav_src21_beta1.zip

What was changed:
1. Properties dialog (Alt+Enter)
2. Support for local long file names up to 1022 characters (remote not checked yet)
3. Encode # sign - but doesn't work with all servers (Ubuntu: Yes, GMX: No)

Please let me know whether it works for you or not!
Author of Total Commander
https://www.ghisler.com
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

Tried it already, works as expected. :)
It shows the user who locked the file in the "Locked by" field.
Cheers!
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

1 observation: the size in the dialog is missing thousand separator - shows 377750 b (368 k).

1 request: would it be possible to show the lock in the "Attr" column? Perhaps as "r---"?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

1 observation: the size in the dialog is missing thousand separator - shows 377750 b (368 k).
Indeed there are currently no localization functions used to handle things like thousands separators, sorry.
1 request: would it be possible to show the lock in the "Attr" column? Perhaps as "r---"?
That's a good idea, I have simply set the "read only" attribute for locked files. Please try it!

You can get a second beta version here:
https://plugins.ghisler.com/beta/webdav_21_beta2.zip
Sources:
https://plugins.ghisler.com/beta/webdav_src21_beta2.zip
Author of Total Commander
https://www.ghisler.com
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

Perfect!
Thanks a lot!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks, I have put it on the official plugins page now!
Author of Total Commander
https://www.ghisler.com
Post Reply