4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/git-media/filter-smudge.rb', line 4
def self.run!
media_buffer = GitMedia.get_media_buffer
can_download = false
sha = STDIN.readpartial(64).lines.first.chomp if STDIN.eof? && sha.length == 40 && sha.match(/^[0-9a-fA-F]+$/) != nil
media_file = File.join(media_buffer, sha.chomp)
if File.exists?(media_file)
STDERR.puts('recovering media : ' + sha)
File.open(media_file, 'r') do |f|
while data = f.read(4096) do
print data
end
end
else
if !can_download
STDERR.puts('media missing, saving placeholder : ' + sha)
puts sha
end
end
else
STDERR.puts('Unknown git-media file format')
print sha
while data = STDIN.read(4096)
print data
end
end
end
|