forked from aptly-dev/aptly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow published repo to reside on different filesystem
Currently packages are hardlinked from the internal pool to the published repo, which requires them to reside on the same filesystem. This precludes mounting the published repo from a remote machine, e.g. via NFS or sshfs, which would be desirable to physically separate the machine hosting the internal pool and signing key from the machine serving the published repo. Autodetect such a setup and, if found, copy files instead of using hardlinks. Add helpers to check whether two given paths reside on the same filesystem and to check whether an already published package file is identical to the one to be published by comparing their MD5 hashes.
- Loading branch information
Showing
3 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
// SameFilesystem checks whether two existing paths reside on the same | ||
// filesystem and can thus be hardlinked | ||
func SameFilesystem(path1, path2 string) (bool, error) { | ||
path1Stat, err := os.Stat(path1) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
path2Stat, err := os.Stat(path2) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
path1Sys := path1Stat.Sys().(*syscall.Stat_t) | ||
path2Sys := path2Stat.Sys().(*syscall.Stat_t) | ||
|
||
return path1Sys.Dev == path2Sys.Dev, nil | ||
} |