mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: properly delete files in the download cache
This commit is contained in:
parent
4273e30b9a
commit
448e2fe1a2
@ -128,10 +128,10 @@ module FileStore
|
|||||||
def cache_file(file, filename)
|
def cache_file(file, filename)
|
||||||
path = get_cache_path_for(filename)
|
path = get_cache_path_for(filename)
|
||||||
dir = File.dirname(path)
|
dir = File.dirname(path)
|
||||||
FileUtils.mkdir_p(dir) unless Dir[dir].present?
|
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
||||||
FileUtils.cp(file.path, path)
|
FileUtils.cp(file.path, path)
|
||||||
# keep latest 500 files
|
# keep latest 500 files
|
||||||
`ls -tr #{CACHE_DIR} | head -n -#{CACHE_MAXIMUM_SIZE} | xargs rm -f`
|
`ls -tr #{CACHE_DIR} | head -n -#{CACHE_MAXIMUM_SIZE} | awk '$0="#{CACHE_DIR}"$0' | xargs rm -f`
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
Loading…
Reference in New Issue
Block a user