Copy partially locked file, overwrite: target is removed

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Copy partially locked file, overwrite: target is removed

Post by *Flint »

Report from the Russian forum.

When PCAD 2006 is running and the file primer.lib opened in it, it is "partially locked". I don't know what that means, but if you have another primer.lib and try to copy the locked primer.lib onto this copy (overwriting it), TC first remove the target file, and then shows a message that the source file cannot be read.

This has also been testing with SpeedCommander 11.6, with the same result. It removes the target file and then shows a message (translated it from Russian into English - so, may be not exact):
Cannot copy "primer.lib"
Error 33: The process cannot access the file as the part of this file is locked by another process.
I don't have PCAD on my computer, so I cannot check it currently...
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48085
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

This is called "record locking". The problem is that Windows returns an error on ReadFile in the middle of the file. There is no chance to know that beforehand. TC would have to read the entire file into memory first, which is just not feasible for very big files! So what happens is that TC starts reading the file (which works), then it truncates the target and starts writing to it. When reading fails, TC shows an error and deletes the target file (which is incomplete and unusable). Unfortunately TC cannot simply rename the target to keep it for this case, because then the special attributes and permissions of that file would be lost.

Record locking is often used for databases, which can be serveral Gigabytes large. The database should be closed before it is copied, e.g. by closing the program first.
Author of Total Commander
https://www.ghisler.com
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

OK, that's what I supposed. Thanks for the explanation.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

[mod]Moved to the TC7 beta discussion forum.

Hacker (Moderator)[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply