Skip to content

Commit ae54a1c

Browse files
committed
feat: remove old portfolios in maintenance
1 parent 9815fd2 commit ae54a1c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

app/helpers/file_helper.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ def unit_dir(unit, create = true)
225225
dir_for_unit_code_and_id(unit.code, unit.id, create)
226226
end
227227

228-
def unit_portfolio_dir(unit, create = true)
228+
def root_portfolio_dir
229229
file_server = Doubtfire::Application.config.student_work_dir
230-
dst = "#{file_server}/portfolio/" # trust the server config and passed in type for paths
230+
"#{file_server}/portfolio/" # trust the server config and passed in type for paths
231+
end
232+
233+
def unit_portfolio_dir(unit, create = true)
234+
dst = root_portfolio_dir
231235

232236
dst << sanitized_path("#{unit.code}-#{unit.id}") << '/'
233237

@@ -674,6 +678,7 @@ def line_wrap(path, width: 160)
674678
module_function :student_work_root
675679
module_function :dir_for_unit_code_and_id
676680
module_function :unit_dir
681+
module_function :root_portfolio_dir
677682
module_function :unit_portfolio_dir
678683
module_function :student_portfolio_dir
679684
module_function :student_portfolio_path

lib/tasks/maintenance.rake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,8 @@ namespace :maintenance do
6363
unit.archive_submissions($stdout)
6464
unit.update(archived: true)
6565
end
66+
67+
puts "Removing old portfolio PDFs"
68+
`find #{FileHelper.root_portfolio_dir} -name "*pdf.old" -exec rm {} \;`
6669
end
6770
end

0 commit comments

Comments
 (0)