Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,18 @@
}

if err := atomicfile.WriteFile(context.Background(), path, data, atomicfile.WithMode(0o600)); err != nil {
return err
// cache.json is reconstructible: a parent-dir fsync failure
// (PhaseDirSync) means the cache was written to disk but its
// durability across an immediate crash is not guaranteed. Don't
// fail the save for that — the data is present and would be rebuilt
// from Plex on the next run anyway. Surface it as a warning instead.
var we *atomicfile.WriteError
if errors.As(err, &we) && we.Phase == atomicfile.PhaseDirSync {

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync) (typecheck)

Check failure on line 130 in internal/cache/cache.go

View workflow job for this annotation

GitHub Actions / ci / go / validate

undefined: atomicfile.PhaseDirSync
slog.Warn("cache written but parent-dir fsync unconfirmed; not guaranteed durable across an immediate crash",
"path", path, "error", err)
} else {
return err
}
}
slog.Debug("cache saved", "path", path, "bytes", len(data))
return nil
Expand Down
Loading