...
 
Commits (2)
  • David Taylor's avatar
    DEV: Raise errors when cleaning the download cache, and fix for macOS (#8319) · 1998be3b
    David Taylor authored
    POSIX's `head` specification states: "The application shall ensure that the number option-argument is a positive decimal integer"
    
    Negative values are supported on GNU `head`, so this works in the discourse docker image. However, in some environments (e.g. macOS), the system `head` version fails with a negative `n` parameter.
    
    This commit does two things:
    
    Checks the status at each stage of the pipe, so it cannot fail silently
    Flip the `ls` command to list in descending time order, and use `tail -n +501` instead of `head -n -500`.
    
    The visible result is that macOS users no longer see head: illegal line count -- -500 printed throughout the test suite.
    1998be3b
  • Mark VanLandingham's avatar
......@@ -151,7 +151,7 @@ var define, requirejs;
}
Module.prototype.makeRequire = function() {
var name = this.name;
var name = transformForAliases(this.name);
return (
this._require ||
......@@ -217,7 +217,7 @@ var define, requirejs;
}
function requireFrom(name, origin) {
name = checkForAlias(name);
name = transformForAliases(name);
var mod = EMBER_MODULES[name] || registry[name];
if (!mod) {
throw new Error(
......@@ -231,7 +231,7 @@ var define, requirejs;
throw new Error("Could not find module " + name);
}
function checkForAlias(name) {
function transformForAliases(name) {
return ALIASES[name] ? ALIASES[name] : name;
}
......
......@@ -139,7 +139,13 @@ module FileStore
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
FileUtils.cp(file.path, path)
# keep latest 500 files
`ls -tr #{CACHE_DIR} | head -n -#{CACHE_MAXIMUM_SIZE} | awk '$0="#{CACHE_DIR}"$0' | xargs rm -f`
processes = Open3.pipeline(
"ls -t #{CACHE_DIR}",
"tail -n +#{CACHE_MAXIMUM_SIZE + 1}",
"awk '$0=\"#{CACHE_DIR}\"$0'",
"xargs rm -f"
)
raise "Error clearing old cache" if !processes.all?(&:success?)
end
private
......