Remove active_support Time extensions
This commit is contained in:
parent
6a8dd4ff52
commit
24e7c2c5bd
@ -46,7 +46,8 @@ module Homebrew
|
||||
|
||||
return true if symlink? && !exist?
|
||||
|
||||
mtime < days.days.ago && ctime < days.days.ago
|
||||
days_ago = (DateTime.now - days).to_time
|
||||
mtime < days_ago && ctime < days_ago
|
||||
end
|
||||
|
||||
def stale?(scrub: false)
|
||||
@ -125,8 +126,8 @@ module Homebrew
|
||||
return true if scrub && cask.versions.exclude?(cask.version)
|
||||
|
||||
if cask.version.latest?
|
||||
return mtime < CLEANUP_DEFAULT_DAYS.days.ago &&
|
||||
ctime < CLEANUP_DEFAULT_DAYS.days.ago
|
||||
cleanup_threshold = (DateTime.now - CLEANUP_DEFAULT_DAYS).to_time
|
||||
return mtime < cleanup_threshold && ctime < cleanup_threshold
|
||||
end
|
||||
|
||||
false
|
||||
@ -202,7 +203,7 @@ module Homebrew
|
||||
return false
|
||||
end
|
||||
|
||||
PERIODIC_CLEAN_FILE.mtime < CLEANUP_DEFAULT_DAYS.days.ago
|
||||
PERIODIC_CLEAN_FILE.mtime < (DateTime.now - CLEANUP_DEFAULT_DAYS).to_time
|
||||
end
|
||||
|
||||
def self.periodic_clean!(dry_run: false)
|
||||
|
@ -65,7 +65,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
limit = args.limit.presence&.to_i
|
||||
end_time = Time.now + limit.minutes if limit
|
||||
end_time = Time.now + (limit * 60) if limit
|
||||
|
||||
until queue.empty? || (end_time && end_time < Time.now)
|
||||
cask = queue.deq
|
||||
@ -101,7 +101,7 @@ module Homebrew
|
||||
last_check_time = state["check_time"]&.then { |t| Time.parse(t) }
|
||||
|
||||
check_time = Time.now
|
||||
if last_check_time && check_time < (last_check_time + 1.day)
|
||||
if last_check_time && check_time < (last_check_time + (DateTime.now + 1).to_time)
|
||||
opoo "Skipping, already checked within the last 24 hours."
|
||||
return
|
||||
end
|
||||
@ -119,7 +119,7 @@ module Homebrew
|
||||
|
||||
if last_time != time || last_file_size != file_size
|
||||
sha256 = begin
|
||||
Timeout.timeout(5.minutes) do
|
||||
Timeout.timeout(5 * 60) do
|
||||
unversioned_cask_checker.installer.download.sha256
|
||||
end
|
||||
rescue => e
|
||||
@ -128,7 +128,7 @@ module Homebrew
|
||||
|
||||
if sha256.present? && last_sha256 != sha256
|
||||
version = begin
|
||||
Timeout.timeout(1.minute) do
|
||||
Timeout.timeout(60) do
|
||||
unversioned_cask_checker.guess_cask_version
|
||||
end
|
||||
rescue Timeout::Error
|
||||
|
@ -13,7 +13,7 @@ require "forwardable"
|
||||
# Only require "core_ext" here to ensure we're only requiring the minimum of
|
||||
# what we need.
|
||||
require "active_support/core_ext/object/blank"
|
||||
require "active_support/core_ext/numeric/time"
|
||||
require "active_support/core_ext/string/filters"
|
||||
require "active_support/core_ext/object/try"
|
||||
require "active_support/core_ext/array/access"
|
||||
require "active_support/core_ext/string/inflections"
|
||||
|
@ -37,8 +37,8 @@ describe Homebrew::Cleanup do
|
||||
end
|
||||
|
||||
it "returns true when ctime and mtime < days_default" do
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return(2.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(2.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return((DateTime.now - 2).to_time)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return((DateTime.now - 2).to_time)
|
||||
expect(path.prune?(1)).to be true
|
||||
end
|
||||
|
||||
@ -186,8 +186,8 @@ describe Homebrew::Cleanup do
|
||||
it "removes the download for the latest version after 30 days" do
|
||||
download = Cask::Cache.path/"#{cask.token}--#{cask.version}"
|
||||
|
||||
allow(download).to receive(:ctime).and_return(30.days.ago - 1.hour)
|
||||
allow(download).to receive(:mtime).and_return(30.days.ago - 1.hour)
|
||||
allow(download).to receive(:ctime).and_return((DateTime.now - 30).to_time - (60 * 60))
|
||||
allow(download).to receive(:mtime).and_return((DateTime.now - 30).to_time - (60 * 60))
|
||||
|
||||
cleanup.cleanup_cask(cask)
|
||||
|
||||
@ -209,15 +209,15 @@ describe Homebrew::Cleanup do
|
||||
end
|
||||
|
||||
it "cleans up logs if older than 30 days" do
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return(31.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(31.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return((DateTime.now - 31).to_time)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return((DateTime.now - 31).to_time)
|
||||
cleanup.cleanup_logs
|
||||
expect(path).not_to exist
|
||||
end
|
||||
|
||||
it "does not clean up logs less than 30 days old" do
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return(15.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return(15.days.ago)
|
||||
allow_any_instance_of(Pathname).to receive(:ctime).and_return((DateTime.now - 15).to_time)
|
||||
allow_any_instance_of(Pathname).to receive(:mtime).and_return((DateTime.now - 15).to_time)
|
||||
cleanup.cleanup_logs
|
||||
expect(path).to exist
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user