mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 10:17:17 +08:00
feat: 规范压缩解压
This commit is contained in:
@@ -134,7 +134,7 @@ func (r *backupRepo) CutoffLog(path, target string) error {
|
||||
}
|
||||
|
||||
to := filepath.Join(path, fmt.Sprintf("%s_%s.zip", time.Now().Format("20060102150405"), filepath.Base(target)))
|
||||
if err := io.Compress(filepath.Dir(target), []string{target}, to); err != nil {
|
||||
if err := io.Compress(filepath.Dir(target), []string{filepath.Base(target)}, to); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ func (r *backupRepo) createMySQL(to string, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = io.Compress(filepath.Dir(backup), []string{backup}, backup+".zip"); err != nil {
|
||||
if err = io.Compress(filepath.Dir(backup), []string{filepath.Base(backup)}, backup+".zip"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Remove(backup); err != nil {
|
||||
@@ -309,7 +309,7 @@ func (r *backupRepo) createPostgres(to string, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = io.Compress(filepath.Dir(backup), []string{backup}, backup+".zip"); err != nil {
|
||||
if err = io.Compress(filepath.Dir(backup), []string{filepath.Base(backup)}, backup+".zip"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = io.Remove(backup); err != nil {
|
||||
|
||||
@@ -50,6 +50,7 @@ type FilePermission struct {
|
||||
}
|
||||
|
||||
type FileCompress struct {
|
||||
Dir string `form:"dir" json:"dir" validate:"required"`
|
||||
Paths []string `form:"paths" json:"paths" validate:"min=1,dive,required"`
|
||||
File string `form:"file" json:"file" validate:"required"`
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ func (s *FileService) Compress(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = io.Compress(filepath.Dir(req.Paths[0]), req.Paths, req.File); err != nil {
|
||||
if err = io.Compress(req.Dir, req.Paths, req.File); err != nil {
|
||||
Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user