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