use md5 instead of name.
This commit is contained in:
@@ -248,7 +248,7 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
|
||||
continue
|
||||
}
|
||||
|
||||
if s.cacheMgr.exists(o.name) {
|
||||
if s.cacheMgr.exists(o.md5) {
|
||||
ctx.Logger().V(5).Info("skipping object, object already processed", "name", o.name)
|
||||
continue
|
||||
}
|
||||
@@ -261,7 +261,7 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
|
||||
ctx.Logger().V(1).Info("error setting start progress progress", "name", o.name, "error", err)
|
||||
return
|
||||
}
|
||||
s.setProgress(ctx, o.name)
|
||||
s.setProgress(ctx, o.name, o.md5)
|
||||
}(o)
|
||||
}
|
||||
wg.Wait()
|
||||
@@ -270,11 +270,11 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Source) setProgress(ctx context.Context, objName string) {
|
||||
func (s *Source) setProgress(ctx context.Context, objName, md5 string) {
|
||||
atomic.AddInt32(&s.processedObjects, 1)
|
||||
ctx.Logger().V(5).Info("setting progress for object", "object-name", objName)
|
||||
ctx.Logger().V(5).Info("setting progress for object", "object-name", objName, "md5", md5)
|
||||
|
||||
s.cacheMgr.set(objName)
|
||||
s.cacheMgr.set(md5)
|
||||
if ok, val := s.cacheMgr.shouldPersist(); ok {
|
||||
s.SetProgressComplete(int(s.processedObjects), int(s.stats.numObjects), fmt.Sprintf("object %s processed", objName), val)
|
||||
return
|
||||
|
||||
@@ -190,6 +190,7 @@ func createTestObject(id int) object {
|
||||
link: fmt.Sprintf("https://storage.googleapis.com/%s/%s", testBucket, fmt.Sprintf("object%d", id)),
|
||||
acl: []string{"authenticatedUsers"},
|
||||
size: 42,
|
||||
md5: fmt.Sprintf("md5hash%d", id),
|
||||
Reader: &mockReader{data: []byte(fmt.Sprintf("hello world %d", id))},
|
||||
}
|
||||
}
|
||||
@@ -326,14 +327,14 @@ func TestSourceChunks_ProgressSet(t *testing.T) {
|
||||
// Ensure we get 5 objects back.
|
||||
assert.Equal(t, len(want), len(got))
|
||||
|
||||
processing := map[string]struct{}{"object0": {}, "object1": {}, "object2": {}, "object3": {}, "object4": {}}
|
||||
processing := map[string]struct{}{"md5hash0": {}, "md5hash1": {}, "md5hash2": {}, "md5hash3": {}, "md5hash4": {}}
|
||||
for i := 0; i < 5; i++ {
|
||||
delete(processing, fmt.Sprintf("object%d", i))
|
||||
}
|
||||
|
||||
// Test that the resume progress is set.
|
||||
// The processed values should be the greatest object name lexicographically.
|
||||
progress := "object0,object1,object2,object3,object4"
|
||||
progress := "md5hash0,md5hash1,md5hash2,md5hash3,md5hash4"
|
||||
objs := strings.Split(progress, ",")
|
||||
|
||||
encodeResume := strings.Split(source.Progress.EncodedResumeInfo, ",")
|
||||
|
||||
Reference in New Issue
Block a user