Skip to content

Commit

Permalink
Fix filestorage (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
reshke authored Aug 15, 2024
1 parent ad1e78b commit f2db008
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/storage/filestorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"io/fs"
"os"
"path"
"path/filepath"

"github.com/yezzey-gp/yproxy/config"
Expand All @@ -18,7 +19,7 @@ type FileStorageInteractor struct {
}

func (s *FileStorageInteractor) CatFileFromStorage(name string, offset int64) (io.ReadCloser, error) {
file, err := os.Open(s.cnf.StoragePrefix + name)
file, err := os.Open(path.Join(s.cnf.StoragePrefix, name))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -49,7 +50,7 @@ func (s *FileStorageInteractor) ListPath(prefix string) ([]*ObjectInfo, error) {
}

func (s *FileStorageInteractor) PutFileToDest(name string, r io.Reader) error {
file, err := os.Create(s.cnf.StoragePrefix + name)
file, err := os.Create(path.Join(s.cnf.StoragePrefix, name))
if err != nil {
return err
}
Expand All @@ -63,9 +64,9 @@ func (s *FileStorageInteractor) PatchFile(name string, r io.ReadSeeker, startOff
}

func (s *FileStorageInteractor) MoveObject(from string, to string) error {
return os.Rename(s.cnf.StoragePrefix+from, s.cnf.StoragePrefix+to)
return os.Rename(path.Join(s.cnf.StoragePrefix, from), path.Join(s.cnf.StoragePrefix, to))
}

func (s *FileStorageInteractor) DeleteObject(key string) error {
return os.Remove(s.cnf.StoragePrefix + key)
return os.Remove(path.Join(s.cnf.StoragePrefix, key))
}

0 comments on commit f2db008

Please sign in to comment.