Skip to content
Snippets Groups Projects
Commit b8f9bbdc authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch 'attachment-delete-service' into 'master'

Attachment delete service

See merge request !349
parents 750d8410 88aa7e80
No related branches found
No related tags found
No related merge requests found
require 'fileutils'
namespace :attachment_maintaining_service do
desc 'Removing 10 attachments'
task remove_attachments: :environment do
m = sort_directories.first(10)
m.each do |mm|
#puts (mm)
FileUtils.rm_r(mm)
end
end
def sort_directories
files_sorted_by_time = Dir[dir_path].sort_by{ |f| File.atime(f) }
files_sorted_by_time
end
private
def dir_path
c = Rails.root.join('public','attachments','*').to_s
c
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment