diff --git a/.github/workflows/server_docker.yml b/.github/workflows/server_docker.yml index 4744cea..7be5815 100644 --- a/.github/workflows/server_docker.yml +++ b/.github/workflows/server_docker.yml @@ -6,6 +6,7 @@ on: - "main" paths-ignore: - 'frontend/**' + - 'cmd/photographer/**' jobs: docker: diff --git a/cmd/photographer/main.go b/cmd/photographer/main.go index db0b873..be65532 100644 --- a/cmd/photographer/main.go +++ b/cmd/photographer/main.go @@ -92,6 +92,5 @@ func execute(ctx context.Context, snapshotStorage *util.SnapshotStorage, history if err != nil { log.Fatalf("%v \n", err) } - snapshotFullPath := "/var/run/tezos/snapshots/" + snapshotfilename - snapshotStorage.EphemeralUpload(ctx, snapshotFullPath) + snapshotStorage.EphemeralUpload(ctx, snapshotfilename) } diff --git a/pkg/util/storage.go b/pkg/util/storage.go index ad00422..b468383 100644 --- a/pkg/util/storage.go +++ b/pkg/util/storage.go @@ -31,6 +31,16 @@ func NewSnapshotStorage(client *storage.Client, bucketName string) *SnapshotStor } func (s *SnapshotStorage) EphemeralUpload(ctx context.Context, filename string) { + // Save the current working directory so we can revert back + currentDir, err := os.Getwd() + if err != nil { + log.Fatalf("Failed to get current directory: %v", err) + } + // Change to the desired directory + if err := os.Chdir("/var/run/tezos/snapshots/"); err != nil { + log.Fatalf("Failed to change directory: %v", err) + } + log.Printf("Opening snapshot file %q.", filename) snapshotFile, err := os.Open(filename) if err != nil { @@ -49,6 +59,7 @@ func (s *SnapshotStorage) EphemeralUpload(ctx context.Context, filename string) if err != nil { log.Fatal(err) } + defer os.Chdir(currentDir) // Ensure we change back to the original directory } func (s *SnapshotStorage) GetTodaySnapshotsItems(ctx context.Context) []snapshot.SnapshotItem {