rejetto forum

delete on mount points

SamePaul · 10 · 19969

0 Members and 1 Guest are viewing this topic.

Offline SamePaul

  • Occasional poster
  • *
    • Posts: 72
    • View Profile
Deletion still doesn't work for me :(
Do you want to publish sources and I will try to find solution? I looked at SF but CVS here is empty and sources are outdated.



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
Deletion still doesn't work for me :(
Do you want to publish sources and I will try to find solution? I looked at SF but CVS here is empty and sources are outdated.

tell me how to reproduce the problem.

in this forum there's a single sticky topic, linking the current sources.


Offline SamePaul

  • Occasional poster
  • *
    • Posts: 72
    • View Profile
Yeah, I found it... Blond moment :)
but thank you anyway


Offline SamePaul

  • Occasional poster
  • *
    • Posts: 72
    • View Profile
Deletion still doesn't work for me :(
Do you want to publish sources and I will try to find solution? I looked at SF but CVS here is empty and sources are outdated.

tell me how to reproduce the problem.
Exactly the same way as I described early
Lets say you have 2 volumes C: and D:
1. On C: make directory Store: md C:\Store
2. Find full volume name for D:. Just type "mountvol" at command line and it will list you all you have. Lets say you see something like
   \\?\Volume{761956c6-24d3-11dc-9f54-000102132ad0}\
    D:\
3. Mount D: at C:\Store "mountvol C:\Store \\?\Volume{761956c6-24d3-11dc-9f54-000102132ad0}\"
(this can be done via gui as well, but long to describe)
4. Now under C:\Store\ you have contents of D:\ . Create D:\TestUP\4del and put there some files.
5. Add C:\Store\TestUP\4del to HFS (important to add via C:\Store and not via D:)
6. Assign delete permission and put "No Download" flag. [upd: "No Download" flag is irrelevant]
7. In web browser navigate to folder /TestUP put checkmark on folder 4del and press "Delete selected". See that folder remains intact wih all the files inside.
8. Navigate inside this folder, select all files and press "Delete selected". All files are deleted. But folder cannot be deleted nevertheless.

Does this reproduce at your side?
« Last Edit: April 22, 2009, 04:42:43 PM by SamePaul »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
from step7 i understand that at step5 i had to add C:\store\testup and no C:\store\testup\4del, right?

anyway, i tested, and actually i saw the problem.
current junction support is limited to junctions that point to drive letters.
i see that mountvol cannot do this, but other utilities can (i use junction.exe by sysinternals).

the problem is that my functions moveToBin() and deleteFile() don't work with file paths like \\?\Volume...
do you have a solution to this?


Offline SamePaul

  • Occasional poster
  • *
    • Posts: 72
    • View Profile
Yes, that correct. "C:\store\testup"  should be added to HFS.

I see you try in code to dereference files, but it won't work in normal use case. On my machine all volumes are mounted under C:\ and no other letters are available.
Don't really understand why you need NtfsDeleteJunctionPoint or NtfsDeleteHardlinks. Didn't find them in sources so don't know what exactly the do.

Yes, I understood what was the problem. HFS tries to use SHFileOperation in order to "delete to Recycle bin" instead of plain deletion. But this function has a bug, because it uses internally file renaming instead of file moving. This bug exists in 2K and XP. On Vista I never tried, but on Win7 it was fixed.

Also I guess that "deleteFile" function doesn't really work on folders. That's why I can freely delete files (no matter  via mountmoint or via drive letter), but not folders. 

So my solution - recursive deleteFolder function which can delete non-empty folders. And option in HFS to not use Recycle Bin :)
Then moveFile would check this option and either fail with appropriate message to user (in case delete-to-bin was chosen) or wipe them out.  And this behavior would be "Known issue" that HFS can't handle because of OS limitations.


UPD:
Or even better - dont use moveToBin directly. Instead write function like smartDelete(filename) which will check "use Recycle Bin" option and perform moveFile or deleteFile/removeDir accordingly. And return True/False on success or failure.

And this way your procedure will look
Code: [Select]
    fs:=NIL;
    for i:=0 to data.postvars.count-1 do
      if sameText('selection', data.postvars.names[i]) then
        begin
        s:=decodeURL(getTill('#', data.postvars.valueFromIndex[i])); // omit #anchors
        s:=urlToPath(s, f);
        if s = '' then continue;

        if not smartDelete(s) then
            continue;
//            begin // this code can be used alternatively
//            reportErrorToUser();
//            continue;
//           end
        smartDelete(s+'.md5');
        smartDelete(s+COMMENT_FILE_EXT);
        addString(s, fs);
        end;
« Last Edit: April 22, 2009, 10:38:56 PM by SamePaul »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
Don't really understand why you need NtfsDeleteJunctionPoint or NtfsDeleteHardlinks. Didn't find them in sources so don't know what exactly the do.

you are right, i don't need them. by using the moveToBin() i never noticed that deleteFile() was not working for folders :)
you didn't find them because it's a 3rd party lib, called JCL.

i noticed that moveToBin() spends a lot of time on mounted things, and then fails, leaving action to other functions.
i guess i should try to know when moveToBin() is going to waste time, and skip it.

Quote
So my solution - recursive deleteFolder function which can delete non-empty folders. And option in HFS to not use Recycle Bin :)

the bin is used only for files deleted via web.
do we really need an option like that? what's the gain?


Offline SamePaul

  • Occasional poster
  • *
    • Posts: 72
    • View Profile

Quote
So my solution - recursive deleteFolder function which can delete non-empty folders. And option in HFS to not use Recycle Bin :)

the bin is used only for files deleted via web.
do we really need an option like that? what's the gain?

That's the point -  I talk only about files deleted via web.
The gain is because moveFile fails on folders via mountpoints. And deleteFile works only with files. That's why you need smartDelete which will optionally try SHFileOperation; then if it fails try check if it file or folder and then use deleteFile or removeDir. But I guess that removeDir is going to fail on non-empty folders, so you need recursively make it empty and then removeDir it.
Again, maybe removeDir can deal with non-empty folders on its own, so you don't need invent wheel. But in case it fails you have to implement recursive algorithm.



Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
ah, i thought you suggested that function mainly to act according to the user option.
i already solved the way you said.