ARK-Builders / arklib

Core of the programs in ARK family
MIT License
1 stars 10 forks source link

`Invalid cross-device link` crash when working with temporary files #70

Closed kirillt closed 7 months ago

kirillt commented 8 months ago

Simplified procedure for atomic writing is "write to a temporary file, then hard link to the destination". This becomes a problem when the "destination" and "temporary file" reside on different filesystems, e.g. /tmp and /home.

Possible solutions:

kirillt commented 8 months ago

Workaround: create the folder for temporary files manually and bind it using export TMPDIR.

gwendalF commented 7 months ago

@kirillt Do you have an example where it failed? It seems that the tempory files are created at the same root than the destination:

    pub fn make_temp(&self) -> Result<TmpFile> {
        TmpFile::create_in(&self.directory)
    }
kirillt commented 7 months ago

@gwendalF usually, temporary folder is always /tmp, but Shelf keeps the data by default in ~/.ark-shelf.

I can double-check later. Maybe it also depends on where the binary is.

kirillt commented 7 months ago

https://github.com/ARK-Builders/arklib/assets/581023/1e6f9a9a-f488-496c-916a-268a08a4ac33

kirillt commented 7 months ago

Solved in #88