Fix old path typo

This commit is contained in:
Melon 2025-01-07 21:26:22 +00:00
parent 7cd63ac46d
commit cb0cb9f39d
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -80,18 +80,19 @@ func (h *Handler) extractTarGzUpload(fileData io.Reader, site, branch string) er
branch = "" branch = ""
} }
siteBranchPath := filepath.Join(site, "@"+branch) siteBranchPath := filepath.Join(site, "@"+branch)
siteBranchOldPath := filepath.Join(site, "old@"+branch)
// try the new "old@[...]" and old "@[...].old" paths // try the new "old@[...]" and old "@[...].old" paths
err := h.storageFs.RemoveAll(siteBranchPath + ".old") err := h.storageFs.RemoveAll(siteBranchPath + ".old")
if err != nil && !errors.Is(err, fs.ErrNotExist) { if err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("failed to remove old site branch %s: %w", siteBranchPath, err) return fmt.Errorf("failed to remove old site branch %s: %w", siteBranchPath, err)
} }
err = h.storageFs.RemoveAll("old" + siteBranchPath) err = h.storageFs.RemoveAll(siteBranchOldPath)
if err != nil && !errors.Is(err, fs.ErrNotExist) { if err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("failed to remove old site branch %s: %w", siteBranchPath, err) return fmt.Errorf("failed to remove old site branch %s: %w", siteBranchPath, err)
} }
err = h.storageFs.Rename(siteBranchPath, "old"+siteBranchPath) err = h.storageFs.Rename(siteBranchPath, siteBranchOldPath)
if err != nil && !errors.Is(err, fs.ErrNotExist) { if err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("failed to save an old copy of the site: %w", err) return fmt.Errorf("failed to save an old copy of the site: %w", err)
} }