handle cases when mounted directory does not exist

This commit is contained in:
Chris Lu 2021-08-28 01:56:56 -07:00
parent 0d8936f6cd
commit a9b41900d8

View file

@ -116,11 +116,15 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour
} }
lastOffsetTsNs, err := getOffset(option.grpcDialOption, *option.filerAddress, RemoteSyncKeyPrefix, int32(dirHash)) lastOffsetTsNs, err := getOffset(option.grpcDialOption, *option.filerAddress, RemoteSyncKeyPrefix, int32(dirHash))
if err == nil && mountedDirEntry.Attributes.Crtime < lastOffsetTsNs/1000000 { if mountedDirEntry != nil {
lastOffsetTs = time.Unix(0, lastOffsetTsNs) if err == nil && mountedDirEntry.Attributes.Crtime < lastOffsetTsNs/1000000 {
glog.V(0).Infof("resume from %v", lastOffsetTs) lastOffsetTs = time.Unix(0, lastOffsetTsNs)
glog.V(0).Infof("resume from %v", lastOffsetTs)
} else {
lastOffsetTs = time.Unix(mountedDirEntry.Attributes.Crtime, 0)
}
} else { } else {
lastOffsetTs = time.Unix(mountedDirEntry.Attributes.Crtime, 0) lastOffsetTs = time.Now()
} }
} else { } else {
lastOffsetTs = time.Now().Add(-*option.timeAgo) lastOffsetTs = time.Now().Add(-*option.timeAgo)