fix access right
This commit is contained in:
@@ -258,7 +258,7 @@ func (l Service) PullCurrent(id, path string, cli *client.Client) error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(path, 0600); err != nil {
|
||||
if err := os.MkdirAll(path, 0740); err != nil {
|
||||
return fmt.Errorf("failed to create destination directory: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ func (c *Client) Pull(gameID, archivePath string) error {
|
||||
|
||||
req.SetBasicAuth(c.username, c.password)
|
||||
|
||||
f, err := os.OpenFile(filepath.Clean(archivePath+".part"), os.O_CREATE|os.O_WRONLY, 0600)
|
||||
f, err := os.OpenFile(filepath.Clean(archivePath+".part"), os.O_CREATE|os.O_WRONLY, 0740)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
@@ -277,7 +277,7 @@ func (c *Client) PullBackup(gameID, uuid, archivePath string) error {
|
||||
|
||||
req.SetBasicAuth(c.username, c.password)
|
||||
|
||||
f, err := os.OpenFile(filepath.Clean(archivePath+".part"), os.O_CREATE|os.O_WRONLY, 0600)
|
||||
f, err := os.OpenFile(filepath.Clean(archivePath+".part"), os.O_CREATE|os.O_WRONLY, 0740)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func init() {
|
||||
}
|
||||
|
||||
datastorepath = filepath.Join(roaming, "cloudsave", "data")
|
||||
err = os.MkdirAll(datastorepath, 0600)
|
||||
err = os.MkdirAll(datastorepath, 0740)
|
||||
if err != nil {
|
||||
panic("cannot make the datastore:" + err.Error())
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func Set(gameID, url string) error {
|
||||
URL: url,
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(filepath.Join(filepath.Join(datastorepath, gameID, "remote.json")), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
f, err := os.OpenFile(filepath.Join(filepath.Join(datastorepath, gameID, "remote.json")), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0740)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func (bi BackupIdentifier) Key() string {
|
||||
func NewLazyRepository(dataRootPath string) (*LazyRepository, error) {
|
||||
if m, err := os.Stat(dataRootPath); err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
if err := os.MkdirAll(dataRootPath, 0600); err != nil {
|
||||
if err := os.MkdirAll(dataRootPath, 0750); err != nil {
|
||||
return nil, fmt.Errorf("failed to make the directory: %w", err)
|
||||
}
|
||||
} else {
|
||||
@@ -137,8 +137,8 @@ func NewLazyRepository(dataRootPath string) (*LazyRepository, error) {
|
||||
func (l *LazyRepository) Mkdir(id Identifier) error {
|
||||
path := l.DataPath(id)
|
||||
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
|
||||
slog.Debug("making directory", "path", path, "id", id, "perm", "0600")
|
||||
return os.MkdirAll(path, 0600)
|
||||
slog.Debug("making directory", "path", path, "id", id, "perm", "0750")
|
||||
return os.MkdirAll(path, 0750)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func (l *LazyRepository) WriteBlob(ID Identifier) (io.Writer, error) {
|
||||
path := l.DataPath(ID)
|
||||
|
||||
slog.Debug("loading write buffer...", "id", ID)
|
||||
dst, err := os.OpenFile(filepath.Clean(filepath.Join(path, "data.tar.gz")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
|
||||
dst, err := os.OpenFile(filepath.Clean(filepath.Join(path, "data.tar.gz")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0740)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open destination file: %w", err)
|
||||
}
|
||||
@@ -195,7 +195,7 @@ func (l *LazyRepository) WriteMetadata(id GameIdentifier, m Metadata) error {
|
||||
path := l.DataPath(id)
|
||||
|
||||
slog.Debug("writing metadata", "id", id, "metadata", m)
|
||||
dst, err := os.OpenFile(filepath.Clean(filepath.Join(path, "metadata.json")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
|
||||
dst, err := os.OpenFile(filepath.Clean(filepath.Join(path, "metadata.json")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0740)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open destination file: %w", err)
|
||||
}
|
||||
@@ -292,7 +292,7 @@ func (l *LazyRepository) ResetLastScan(id GameIdentifier) error {
|
||||
path := l.DataPath(id)
|
||||
|
||||
slog.Debug("resetting last scan datetime for", "id", id)
|
||||
f, err := os.OpenFile(filepath.Clean(filepath.Join(path, ".last_run")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
|
||||
f, err := os.OpenFile(filepath.Clean(filepath.Join(path, ".last_run")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0740)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
@@ -325,7 +325,7 @@ func (l *LazyRepository) ReadBlob(id Identifier) (io.ReadSeekCloser, error) {
|
||||
func (l *LazyRepository) SetRemote(id GameIdentifier, url string) error {
|
||||
path := l.DataPath(id)
|
||||
|
||||
src, err := os.OpenFile(filepath.Clean(filepath.Join(path, "remote.json")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
|
||||
src, err := os.OpenFile(filepath.Clean(filepath.Join(path, "remote.json")), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0740)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open remote description: %w", err)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func Untar(file io.Reader, path string) error {
|
||||
// if its a dir and it doesn't exist create it
|
||||
case tar.TypeDir:
|
||||
if _, err := os.Stat(target); err != nil {
|
||||
if err := os.MkdirAll(target, 0600); err != nil {
|
||||
if err := os.MkdirAll(target, 0740); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user