summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-store/storage/fs.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-05-08 19:49:45 +0200
committerLibravatar GitHub <noreply@github.com>2022-05-08 18:49:45 +0100
commit5004e0a9da665ccc0e18cd4075ee636641b71f0a (patch)
treeb7c8269b954ced61afa9fffd7305bd88acca6f8e /vendor/codeberg.org/gruf/go-store/storage/fs.go
parent[bugfix] Fix existing bio text showing as HTML (#531) (diff)
downloadgotosocial-5004e0a9da665ccc0e18cd4075ee636641b71f0a.tar.xz
[bugfix] Fix remote media pruning failing if media already gone (#548)
* fix error check of prune to allow missing files * update go-store library, add test for pruning item with db entry but no file Signed-off-by: kim <grufwub@gmail.com> * remove now-unneccessary error check Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-store/storage/fs.go')
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/fs.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/vendor/codeberg.org/gruf/go-store/storage/fs.go b/vendor/codeberg.org/gruf/go-store/storage/fs.go
index b1c3560d2..b4729b041 100644
--- a/vendor/codeberg.org/gruf/go-store/storage/fs.go
+++ b/vendor/codeberg.org/gruf/go-store/storage/fs.go
@@ -9,8 +9,8 @@ import (
const (
// default file permission bits
- defaultDirPerms = 0755
- defaultFilePerms = 0644
+ defaultDirPerms = 0o755
+ defaultFilePerms = 0o644
// default file open flags
defaultFileROFlags = syscall.O_RDONLY
@@ -22,7 +22,7 @@ const (
// These functions are for opening storage files,
// not necessarily for e.g. initial setup (OpenFile)
-// open should not be called directly
+// open should not be called directly.
func open(path string, flags int) (*os.File, error) {
var fd int
err := util.RetryOnEINTR(func() (err error) {
@@ -35,7 +35,7 @@ func open(path string, flags int) (*os.File, error) {
return os.NewFile(uintptr(fd), path), nil
}
-// stat checks for a file on disk
+// stat checks for a file on disk.
func stat(path string) (bool, error) {
var stat syscall.Stat_t
err := util.RetryOnEINTR(func() error {
@@ -49,3 +49,17 @@ func stat(path string) (bool, error) {
}
return true, nil
}
+
+// unlink removes a file (not dir!) on disk.
+func unlink(path string) error {
+ return util.RetryOnEINTR(func() error {
+ return syscall.Unlink(path)
+ })
+}
+
+// rmdir removes a dir (not file!) on disk.
+func rmdir(path string) error {
+ return util.RetryOnEINTR(func() error {
+ return syscall.Rmdir(path)
+ })
+}