From 1ae226bb3ad23bbd25aa38f0e65cbd6f74b67cf2 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 23 Feb 2021 19:16:58 -0300 Subject: [PATCH] arreglos a la subida de archivos --- app/models/metadata_file.rb | 8 ++++++++ app/views/posts/attributes/_file.haml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/metadata_file.rb b/app/models/metadata_file.rb index f2e69e7..f976a9d 100644 --- a/app/models/metadata_file.rb +++ b/app/models/metadata_file.rb @@ -123,10 +123,18 @@ class MetadataFile < MetadataTemplate # # @return [Boolean] def hardlink + return true if hardlink? + FileUtils.mkdir_p(File.dirname(destination_path)) FileUtils.ln(uploaded_path, destination_path).zero? end + def hardlink? + File.stat(uploaded_path).ino == File.stat(destination_path).ino + rescue Errno::ENOENT + false + end + # Obtener la ruta al archivo # https://stackoverflow.com/a/53908358 def uploaded_relative_path diff --git a/app/views/posts/attributes/_file.haml b/app/views/posts/attributes/_file.haml index 54f87b5..19175b9 100644 --- a/app/views/posts/attributes/_file.haml +++ b/app/views/posts/attributes/_file.haml @@ -1,5 +1,5 @@ .form-group - - if metadata.uploaded? + - if metadata.static_file = hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path'] - case metadata.static_file.blob.content_type