3 ms·
Question: would creating a symlink via ln -s also work instead of doing mv? That would be less risky and more performant compared to moving across filesystems.
by noisy_boy 6y ago
Question: would creating a symlink via ln -s also work instead of doing mv? That would be less risky and more performant compared to moving across filesystems.
- tetha 6y agoI'd say that depends on the retention requirements of the recording folder and the public folder. If you symlink "./public/recording" to "./recording", the public file only exists as long as the original file exists. Some automated cleanup could result in unexpected file deletions from "public/" (or, more specifically, the creation of dangling symlinks). However, this might be a use case for a hard link if you need the file in both places and both directories are on the same filesystem. Though I haven't thought about the implications of a hard link in this case enough so far.
- gvb 6y agoActually, creating a hard link "ln" (no -s) would be the best choice. With the hard link, there are two directory entries pointing to the same data on the disk. At that point, removing the original with a "rm" unlinks the original but the new directory entry for the file remains. As a bonus, ln will not overwrite the destination file if you mistakenly try to "ln" it to an existing file.
- pietrovismara 6y agoThanks for teaching me I can use "ln" without "-s". I used it for years and never thought about it.
- noisy_boy 6y agoTo best of my knowledge, hardlinks do not work across filesystems; softlinks do not have any such issues. Orphan links can be detected and cleared separately.
- angry_octet 6y agoThe httpd should not follow the symlink across filesystems (or arguably, follow symlinks at all) and hence the file would be inaccessible.