Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)

Bug reports will be moved here when the described bug has been fixed

Moderators: sheep, Hacker, Stefan2, white

Post Reply
sspear
Junior Member
Junior Member
Posts: 11
Joined: 2017-02-02, 14:51 UTC

Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)

Post by *sspear »

This is important, because OneDrive uses the file attribute Pinned (Pinned = 0x00080000) for file 'availability' (green checkmark is filled or unfilled in Windows Explorer).

Note that when Windows Explorer is used to rename the file, the Pinned file attribute is preserved.

::Display WIndows 1909 version.
C:\xx>ver
Microsoft Windows [Version 10.0.18363.657]

C:\xx>echo > junk.bak
C:\xx>attrib *
A C:\xx\junk.bak

C:\xx>attrib * +P
C:\xx>attrib *
A P C:\xx\junk.bak

::Switch to Total Commander to rename the file to junk.txt (use either SHIFT+F6 or the Mult-Rename tool)
::note the P attribute is no longer set
C:\xx>attrib *
A C:\xx\junk.txt

::Set the P attribute again
C:\xx>attrib * +p
C:\xx>attrib *
A P C:\xx\junk.txt

::Switch to Windows Explorer to rename the file 'junk.txt' to 'junk.bak' (use F2 or right click Rename)
::note that the P attribute is preserved
C:\xx>attrib *
A P C:\xx\junk.bak
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 39980
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)

Post by *ghisler(Author) »

I need more information:
1. What do you mean with "pinned"? Do you mean "offline only"? I ask because 0x80000 is not described by Microsoft:
https://docs.microsoft.com/de-de/windows/win32/fileio/file-attribute-constants

2. When a file has at least one of the attributes "read only", "hidden", or "system", Total Commander calls SetFileAttributes(name,FILE_ATTRIBUTE_ARCHIVE) because otherwise rename would fail. Does the file have one of these set?

3. When none of these is set, Total Commander calls directly MoveFileEx.

4. In my tests, renaming a file which is only available online doesn't get available when renaming it, whether it has read only set or not
Author of Total Commander
http://www.ghisler.com
sspear
Junior Member
Junior Member
Posts: 11
Joined: 2017-02-02, 14:51 UTC

Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)

Post by *sspear »

Thanks for looking into this.
Sorry to be so circular, but by PINNED I mean the PINNED file attribute is set.
I think Microsoft OneDrive uses the PINNED file attribute to consider a file 'always available', that is:
  • both locally on disk and in the cloud
  • Windows File Explorer shows a solid green checkmark for the file Status
Yes, the file attribute PINNED is not well documented. It is mentioned in the help for the DOS command attrib:

Code: Select all

attrib /?
Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+X | -X] [+P | -P] [+U | -U]
       [drive:][path][filename] [/S [/D]] [/L]

  +   Sets an attribute.
  -   Clears an attribute.
  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  O   Offline attribute.
  I   Not content indexed file attribute.
  X   No scrub file attribute.
  V   Integrity attribute.
  P   Pinned attribute.
  U   Unpinned attribute.
  B   SMR Blob attribute.
  [drive:][path][filename]
      Specifies a file or files for attrib to process.
  /S  Processes matching files in the current folder
      and all subfolders.
  /D  Processes folders as well.
  /L  Work on the attributes of the Symbolic Link versus
      the target of the Symbolic Link
Here are some sites I found when doing a web search for file attribute pinned.

Comment from the 7zip developer, Igor Pavlov about it:
https://sourceforge.net/p/p7zip/bugs/200

Comment (dated Jan 20 '18), says it's in a version of winnt.h. Also a comment above it says the latest SDK headers have it.
https://superuser.com/questions/1214542/what-do-new-windows-8-10-attributes-mean-no-scrub-file-x-integrity-v-pinn

(in German) shows the various icons displayed by Windows File Explorer depending on the file attribute pinned setting and how it is used in Microsoft OneDrive:
https://hansbrender.com/2017/12/29/files-on-demand-der-umgang-mit-den-drei-status-teil-2


Here's a DOS CMD session using the DOS commands ATTRIB and REN showing that the file attribute PINNED is preserved.

Code: Select all

c:\>cd xx

c:\xx>attrib *
A                    C:\xx\junk.bak

c:\xx>attrib * +P

c:\xx>attrib *
A            P       C:\xx\junk.bak

c:\xx>ren junk.bak junk.txt

c:\xx>attrib *
A            P       C:\xx\junk.txt
Here is what I see after I use Total Commander to rename file 'junk.txt' to 'junk.bak' (The PINNED attribute is no longer set.):

Code: Select all

c:\xx>attrib *
A                    C:\xx\junk.bak
My guess is that the Microsoft REN command is using an undocumented/poorly documented feature.
User avatar
DrShark
Power Member
Power Member
Posts: 1625
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)

Post by *DrShark »

BTW, a similar bug with Not Content Indexed attribute being lost after rename has been fixed in Total Commander 9.50 beta 1: https://ghisler.ch/board/viewtopic.php?f=28&t=52897
Android 4.3.1 no root, kernel 08.09.2016; Win7 Home Premium SP1 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 39980
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)

Post by *ghisler(Author) »

I see - apparently it's for the option "Always keep on this device" in the context menu. I could reproduce the problem and found a solution.
It's very unfortunate that this flag isn't documented, it would allow me to show a special overlay icon for "always kept" files.
Author of Total Commander
http://www.ghisler.com
sspear
Junior Member
Junior Member
Posts: 11
Joined: 2017-02-02, 14:51 UTC

Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)

Post by *sspear »

I can verify that this is fixed in TC 9.5 RC2.
Post Reply