added copying and moving

This commit is contained in:
Daniel Goc
2026-04-03 11:25:16 +02:00
parent 395d670298
commit a988bbbc33
7 changed files with 201 additions and 0 deletions

View File

@@ -46,6 +46,35 @@ func (s *StorageService) DownloadFilePrep(abs_path string) (*os.File, string, in
return f, filepath.Base(abs_path), info.Size(), nil
}
func (s *StorageService) Move(src_abs_path string, dest_abs_path string) error {
_, err := s.storageRepo.EntryInfo(src_abs_path)
if err != nil {
return responseErrors.ErrFileDoesNotExist
}
if err == nil {
return responseErrors.ErrNameTaken
} else if os.IsNotExist(err) {
return s.storageRepo.Move(src_abs_path, dest_abs_path)
} else {
return err
}
}
func (s *StorageService) Copy(src_abs_path string, dest_abs_path string) error {
_, err := s.storageRepo.EntryInfo(src_abs_path)
if err != nil {
return responseErrors.ErrFileDoesNotExist
}
if err == nil {
return responseErrors.ErrNameTaken
} else if os.IsNotExist(err) {
return s.storageRepo.Copy(src_abs_path, dest_abs_path)
} else {
return err
}
}
func (s *StorageService) UploadFile(c fiber.Ctx, abs_path string, f *multipart.FileHeader) error {
info, err := s.storageRepo.EntryInfo(abs_path)
if err != nil || !info.IsDir() {