kart icon indicating copy to clipboard operation
kart copied to clipboard

LFS files are duplicated where COW is not supported

Open olsen232 opened this issue 1 year ago • 1 comments

On Windows - and potentially other platforms, depending on the filesystem - copy-on-write is not supported. Currently, Kart simply does a regular copy, which means all LFS files that are checked out in the working copy are also present in the LFS cache, which is inefficient use of disk space.

There is more than one possible fix:

One is to lock the files: make the files readonly, require the user to notify Kart before editing making any edits to them, and at the time that the user asks to edit a file, Kart will make a copy of that file (ie, change the file from being a symlink to the original, to a copy of the original).

Another is to let the user edit the files, but try to detect which ones the user has edited - using hashes and timestamps, much like our/Git's current change detection logic. If we detect file is edited, it should be evicted from the LFS cache before we use it for anything which we need the original file for. The actual original can be re-downloaded from the remote. However, note that this only works if there is a remote - if the files were committed locally and haven't been pushed, the LFS cache is the only place they have been stored, so in this case we would need to use one of the other behaviours (multiple copies of the same file, or locked files to prevent edits before we are ready).

olsen232 avatar Jan 19 '23 02:01 olsen232