This forum has been archived. All content is frozen. Please use KDE Discuss instead.

File operations on 'busy' directories

50

Votes
50
0
Tags: None
(comma "," separated)
opiesche
Registered Member
Posts
5
Karma
0
OS

File operations on 'busy' directories

Fri Mar 20, 2009 10:20 pm
Say you're moving a folder from one location to another; in the meantime, you attempt to edit a text file in that folder with Kate, and save it. As mentioned in the tutorials,

"if you are Moving, Copying or Deleting large directories then you need to use the icon to monitor the progress of your operation.
If you don't then any subsequent actions you do, may well use an incomplete file structure resulting in corrupted files."

This is not good. Don't get me wrong, every DE/OS does the same thing, but it's still not good. Since KDE knows which files/directories are currently being copied, moved, or deleted, is there a way to hook into routines that save files and warn the user if this is the case?
This is definitely not trivially accomplished, because I imagine most apps just save their files by doing an fopen/fwrite/fclose, but if this can be caught and handled via a warning to the user, the user experience in cases like this would be much improved.
An option is, of course, to take an exclusive lock on files and directories that are the source of an active move operation, but that comes with its own set of issues. It would be nice to work out some general guidelines as to what happens in different cases and which warnings should be presented to the user; for example,

-if the user saves a file to a directory that is currently being copied to, warn the user with 'This file is subject to an active copy operation that has not yet completed. Saving now may have unexpected results.'; possibly also pop open the notification for the copy operation the warning is talking about.

-if the user saves a file to a directory that is currently being deleted, warn with 'This file is part of an ongoing delete operation. Saving now will result in the saved data being deleted from the destination location.'; again, pop up the notification for the delete operation.

and many other possibilities, of course.

This is a very specific example for a very general philosophy: corrupting data should be avoided if at all possible, and if there's a good chance that the user will end up with a result different from what his save operation normally yields, he should at least be warned about it. I realize that this is potentially opening a big can of worms, but I think it's one worth looking into. The first time a user sees this notification, they're going to be thankful for it.
User avatar
Madman
Registered Member
Posts
593
Karma
1
OS

File operations on 'busy' directories

Sun Sep 27, 2009 12:02 pm
Anything that makes oblivious users more informed and protects them is a good idea, methinks. :)


Madman, proud to be a member of KDE forums since 2008-Oct.
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
I think this would be difficult to implement, but I think it is a very good idea if feasible.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
opiesche
Registered Member
Posts
5
Karma
0
OS
Catching these file operations before they happen could mean overriding libc these functions in libc and possibly corresponding libs for other programming languages - tricky business, but possible.
They could be wrapped with functions from, say, a new KDE library, that checks for ongoing progress on these files, and then presents warnings and/or pipes through to the original libc function.
This would even open other possibilities - for example, saving a text file in Kate while that file is being moved could cancel the move operation and simply redirect the file write to the new location, possibly letting Kate know what's going on so it can update its file path as well.
Wrapping the file access functions could make it possible to make all kinds of file operations much more robust and even make things like moving whole directories while they're being written to 'just work', if the apps are intelligent enough to handle appropriate notificiations.
zbikenut
Registered Member
Posts
1
Karma
0
Madman wrote:Anything that makes oblivious users more informed and protects them is a good idea, methinks. :)


Newbies need all the warnings we can get.
Lachu
Registered Member
Posts
864
Karma
1
OS
You have right.

Many programs are not designed for that. It does some think like:

open, read, close

and next:

open, write, close


If programs don't let close fd, there's not matter about moving files.


Lachu, proud to be a member of KDE forums since 2008-Nov.


Bookmarks



Who is online

Registered users: Bing [Bot], gfielding, Google [Bot], Sogou [Bot]