Skip to content

Commit

Permalink
fix it differently
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilevos committed Aug 18, 2023
1 parent 067a4f8 commit d656582
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/server_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- "main"
paths-ignore:
- 'frontend/**'
- 'cmd/photographer/**'

jobs:
docker:
Expand Down
3 changes: 1 addition & 2 deletions cmd/photographer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
11 changes: 11 additions & 0 deletions pkg/util/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit d656582

Please sign in to comment.