Rework archiving logic to be more consistent and less impactful on disk IO (#79)

Co-authored-by: Dane Everitt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner
2020-12-25 12:52:57 -07:00
committed by GitHub
parent c0523df696
commit 901ab1157d
11 changed files with 262 additions and 350 deletions

View File

@@ -1,10 +1,10 @@
package backup
import (
"context"
"fmt"
"github.com/apex/log"
"github.com/pterodactyl/wings/api"
"github.com/pterodactyl/wings/server/filesystem"
"io"
"net/http"
"os"
@@ -19,15 +19,15 @@ var _ BackupInterface = (*S3Backup)(nil)
// Generates a new backup on the disk, moves it into the S3 bucket via the provided
// presigned URL, and then deletes the backup from the disk.
func (s *S3Backup) Generate(included *IncludedFiles, prefix string) (*ArchiveDetails, error) {
func (s *S3Backup) Generate(basePath, ignore string) (*ArchiveDetails, error) {
defer s.Remove()
a := &Archive{
TrimPrefix: prefix,
Files: included,
a := &filesystem.Archive{
BasePath: basePath,
Ignore: ignore,
}
if err := a.Create(s.Path(), context.Background()); err != nil {
if err := a.Create(s.Path()); err != nil {
return nil, err
}