このコミットが含まれているのは:
2026-06-23 22:05:11 +09:00
コミット 507ce1680e
25個のファイルの変更1148行の追加111行の削除
+25
ファイルの表示
@@ -0,0 +1,25 @@
require 'digest'
class MaterialFileSha256
def self.from_blob blob
sha256 = blob.metadata['sha256']
return sha256 if sha256.present?
blob.open do |file|
sha256 = Digest::SHA256.file(file.path).hexdigest
blob.metadata['sha256'] = sha256
blob.save! if blob.changed?
sha256
end
end
def self.from_upload upload
tempfile = upload&.tempfile
return nil unless tempfile
tempfile.rewind
Digest::SHA256.file(tempfile.path).hexdigest.tap do
tempfile.rewind
end
end
end