Promps users for updating spritepack files

This commit is contained in:
chardub
2025-03-06 18:57:43 -05:00
parent ccb05dc509
commit d9ef1cd12e
8 changed files with 25 additions and 12 deletions

View File

@@ -43,6 +43,7 @@ def download_file(url, saveLocation)
return saveLocation
else
echoln _INTL("Failed to download file {1}", url)
echoln caller
end
return nil
rescue MKXPError, Errno::ENOENT => error
@@ -72,6 +73,7 @@ def fetch_sprite_from_web(url, destinationPath)
return true
end
echoln "Failed to download #{url}"
echoln caller
return false
rescue MKXPError => e
echoln "MKXPError: #{e.message}"
@@ -85,8 +87,7 @@ def fetch_sprite_from_web(url, destinationPath)
end
def download_spritesheet(pif_sprite, dest)
#return nil if requestRateExceeded?(Settings::CUSTOMSPRITES_RATE_LOG_FILE,Settings::CUSTOMSPRITES_ENTRIES_RATE_TIME_WINDOW,Settings::CUSTOMSPRITES_RATE_MAX_NB_REQUESTS)
return nil if requestRateExceeded?(Settings::CUSTOMSPRITES_RATE_LOG_FILE, 60, 15)
return nil if requestRateExceeded?(Settings::CUSTOMSPRITES_RATE_LOG_FILE,Settings::CUSTOMSPRITES_ENTRIES_RATE_TIME_WINDOW,Settings::CUSTOMSPRITES_RATE_MAX_NB_REQUESTS)
case pif_sprite.type
when :AUTOGEN
return
@@ -420,8 +421,8 @@ def requestRateExceeded?(logFile, timeWindow, maxRequests, update_log_file = tru
# Write the updated log back to the file
if update_log_file
File.write(logFile, request_timestamps.join("\n"))
echoln "Rate limiting: Current: #{request_timestamps.size}, Max: #{maxRequests}"
end
echoln "Rate limiting: Current: #{request_timestamps.size}, Max: #{maxRequests}"
rateLimitExceeded = request_timestamps.size > maxRequests
return rateLimitExceeded
end