5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-10-07 19:36:55 +00:00

Merge branch 'issue-9361' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2023-03-25 15:23:37 -03:00
commit b855d10535
2 changed files with 12 additions and 9 deletions

View file

@ -4,11 +4,6 @@ module ActiveStorage
class Service
# Sube los archivos a cada repositorio y los agrega al LFS de su
# repositorio git.
#
# @todo: Implementar LFS. No nos gusta mucho la idea porque duplica
# el espacio en disco, pero es la única forma que tenemos (hasta que
# implementemos IPFS) para poder transferir los archivos junto con el
# sitio.
class JekyllService < Service::DiskService
# Genera un servicio para un sitio determinado
#
@ -27,7 +22,10 @@ module ActiveStorage
# @param :checksum [String]
def upload(key, io, checksum: nil, **)
instrument :upload, key: key, checksum: checksum do
IO.copy_stream(io, make_path_for(key)) unless exist?(key)
unless exist?(key)
IO.copy_stream(io, make_path_for(key))
LfsObjectService.new(site: site, usuarie: current_usuarie, blob: blob).process
end
ensure_integrity_of(key, checksum) if checksum
end
end
@ -91,6 +89,11 @@ module ActiveStorage
def path_for(key)
File.join root, folder_for(key), filename_for(key)
end
# @return [Site]
def site
@site ||= Site.find_by_name(File.basename(root))
end
end
end
end

View file

@ -29,7 +29,7 @@ class LfsObjectService
FileUtils.rm(path)
# Hacer link duro del objeto al archivo
FileUtils.hardlink(object_path, path)
FileUtils.ln(object_path, path)
end
# @return [String]
@ -39,7 +39,7 @@ class LfsObjectService
# @return [String]
def digest
@digest ||= Digest::SHA256.file(path)
@digest ||= Digest::SHA256.file(path).hexdigest
end
# @return [String]
@ -49,7 +49,7 @@ class LfsObjectService
# @return [Integer]
def size
@size ||= File.size(path)
@size ||= File.size(File.exist?(object_path) ? object_path : path)
end
# @return [String]