5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 06:34:16 +00:00

feat: commitear el archivo en lfs al subirlo

This commit is contained in:
f 2023-03-25 15:22:54 -03:00
parent 960c8dcca4
commit 2215a00727
2 changed files with 10 additions and 7 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

@ -44,7 +44,7 @@ class LfsObjectService
# @return [String]
def object_path
@git_lfs_object_path ||= File.join(site.path, '.git', 'lfs', 'objects', digest[0..1], digest[2..3], digest)
@object_path ||= File.join(site.path, '.git', 'lfs', 'objects', digest[0..1], digest[2..3], digest)
end
# @return [Integer]