From 0928e53a8b425a1aa7a5f9c81ecc4a8ed4b9d949 Mon Sep 17 00:00:00 2001 From: Ashlie Martinez Date: Wed, 1 Feb 2023 16:29:32 -0800 Subject: [PATCH] Add interface to get version of item Pass version as UID in OwnerInfo to kopia to allow more control of what kopia thinks is a cached file. --- src/internal/data/data_collection.go | 4 ++++ src/internal/kopia/upload.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/internal/data/data_collection.go b/src/internal/data/data_collection.go index 0e3d492e0..791f0cdab 100644 --- a/src/internal/data/data_collection.go +++ b/src/internal/data/data_collection.go @@ -87,6 +87,10 @@ type StreamModTime interface { ModTime() time.Time } +type Versioner interface { + Version() uint32 +} + // ------------------------------------------------------------------------------------------------ // functionality // ------------------------------------------------------------------------------------------------ diff --git a/src/internal/kopia/upload.go b/src/internal/kopia/upload.go index 8ddb46978..d35db8bcf 100644 --- a/src/internal/kopia/upload.go +++ b/src/internal/kopia/upload.go @@ -339,9 +339,15 @@ func collectionEntries( modTime = smt.ModTime() } + o := fs.OwnerInfo{} + if sv, ok := e.(data.Versioner); ok { + o.UserID = sv.Version() + } + entry := virtualfs.StreamingFileWithModTimeFromReader( encodedName, modTime, + o, newBackupStreamReader(serializationVersion, e.ToReader()), ) if err := cb(ctx, entry); err != nil {