From 10fb5c8f3f756ae6b66edf78dc49e4f20e03c673 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 4 Sep 2016 22:34:14 +0200 Subject: [PATCH] Update files in the cache on save --- src/restic/repository/repository.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/restic/repository/repository.go b/src/restic/repository/repository.go index 6088af4ad..3fd7b743d 100644 --- a/src/restic/repository/repository.go +++ b/src/restic/repository/repository.go @@ -322,7 +322,17 @@ func (r *Repository) SaveUnpacked(t restic.FileType, p []byte) (id restic.ID, er return restic.ID{}, err } - debug.Log("Repo.SaveJSONUnpacked", "blob %v saved", h) + // store file in the cache + if r.cache != nil && (t == restic.IndexFile || t == restic.SnapshotFile) { + h := restic.Handle{Name: id.String(), Type: t} + err := r.cache.PutFile(h, p) + if err != nil { + return restic.ID{}, err + } + debug.Log("Repo.Save", "updated file %v in cache", h) + } + + debug.Log("Repo.SaveJSONUnpacked", "file %v saved", h) return id, nil }