There was an error while loading. Please reload this page.
1 parent f5e1f17 commit 52e397eCopy full SHA for 52e397e
lib/git-media/transport/s3.rb
@@ -45,12 +45,23 @@ def put_file(sha, from_file)
45
end
46
47
def get_unpushed(files)
48
- keys = @s3.list_bucket(@bucket).map { |f| f[:key] }
+ # Using a set instead of a list improves performance a lot
49
+ # since it reduces the complexity from O(n^2) to O(n)
50
+ keys = Set.new()
51
+
52
+ # Apparently the list_bucket method only returns the first 1000 elements
53
+ # This method however will continue to give back results until all elements
54
+ # have been listed
55
+ @s3.incrementally_list_bucket(@bucket) { |contents|
56
+ contents[:contents].each { |element|
57
+ keys.add (element[:key])
58
+ }
59
60
61
files.select do |f|
62
!keys.include?(f)
63
64
-
65
66
-end
67
+end
0 commit comments