From db9596d2236977f4e74ebf46e95ef8ef52ec5914 Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Wed, 27 Sep 2023 16:07:59 -0700 Subject: [PATCH] Use non-zero time as fallback (#4390) Use a non-zero time as the fallback for the mod time of an item during enumeration. This should avoid an issue where the mod time in details differs from the mod time in kopia due to a serialization issue. --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [x] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Test Plan - [ ] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/pkg/services/m365/api/item_pager.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pkg/services/m365/api/item_pager.go b/src/pkg/services/m365/api/item_pager.go index 3cd1deb53..5effcb7a6 100644 --- a/src/pkg/services/m365/api/item_pager.go +++ b/src/pkg/services/m365/api/item_pager.go @@ -289,7 +289,15 @@ func addedAndRemovedByDeletedDateTime[T any]( var modTime time.Time if mt, ok := giaddt.(getModTimer); ok { - modTime = ptr.Val(mt.GetLastModifiedDateTime()) + // Make sure to get a non-zero mod time if the item doesn't have one for + // some reason. Otherwise we can hit an issue where kopia has a + // different mod time for the file than the details does. This occurs + // due to a conversion kopia does on the time from + // time.Time -> nanoseconds for serialization. During incremental + // backups, kopia goes from nanoseconds -> time.Time but there's an + // overflow which yields a different timestamp. + // https://github.com/gohugoio/hugo/issues/6161#issuecomment-725915786 + modTime = ptr.OrNow(mt.GetLastModifiedDateTime()) } added[ptr.Val(giaddt.GetId())] = modTime