Adds “Disable Response Caching” debug setting

When enabled, AltStore will ignore cached responses for certain requests and will always make a new request to the server. This is useful for development when repeatedly testing changes to remote files.

Limited to UpdateKnownSourcesOperation for now, but will eventually affect fetching sources as well.
This commit is contained in:
Riley Testut
2023-05-29 12:10:44 -05:00
committed by Magesh K
parent a38eba8449
commit 86ae06e0c8
4 changed files with 50 additions and 8 deletions

View File

@@ -30,11 +30,26 @@ extension UpdateKnownSourcesOperation
class UpdateKnownSourcesOperation: ResultOperation<([KnownSource], [KnownSource])>
{
private let session: URLSession
override init()
{
let configuration = URLSessionConfiguration.default
if UserDefaults.standard.responseCachingDisabled
{
configuration.requestCachePolicy = .reloadIgnoringLocalCacheData
configuration.urlCache = nil
}
self.session = URLSession(configuration: configuration)
}
override func main()
{
super.main()
let dataTask = URLSession.shared.dataTask(with: .sources) { (data, response, error) in
let dataTask = self.session.dataTask(with: .sources) { (data, response, error) in
do
{
if let response = response as? HTTPURLResponse

View File

@@ -729,15 +729,15 @@
<segue destination="GBh-rB-juy" kind="show" identifier="showRefreshAttempts" id="K2i-nF-6qa"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="51" id="rE2-P4-OaE" customClass="InsetGroupTableViewCell" customModule="SideStore" customModuleProvider="target">
<rect key="frame" x="0.0" y="1074" width="375" height="51"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="51" id="XW5-Zc-nMH" customClass="InsetGroupTableViewCell" customModule="AltStore" customModuleProvider="target">
<rect key="frame" x="0.0" y="1201" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="rE2-P4-OaE" id="qIT-rz-ZUb">
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="XW5-Zc-nMH" id="AtM-bL-7pS">
<rect key="frame" x="0.0" y="0.0" width="375" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="View Error Log" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PWC-OG-5jx">
<rect key="frame" x="30" y="15.5" width="119" height="20.5"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Disable Response Caching" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2ox-HD-0UT">
<rect key="frame" x="30" y="15.5" width="215.5" height="20.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
@@ -887,6 +887,19 @@
<constraint firstAttribute="trailingMargin" secondItem="0dh-yd-7i9" secondAttribute="trailing" id="TFW-nu-jo4"/>
<constraint firstItem="eds-Dj-36y" firstAttribute="centerY" secondItem="yjL-Mu-HTk" secondAttribute="centerY" id="YiJ-OF-FXE"/>
</constraints>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="e30-w4-5fk">
<rect key="frame" x="296" y="10" width="51" height="31"/>
<connections>
<action selector="toggleDisableResponseCaching:" destination="aMk-Xp-UL8" eventType="valueChanged" id="uuG-Gf-7GK"/>
</connections>
</switch>
</subviews>
<constraints>
<constraint firstItem="2ox-HD-0UT" firstAttribute="centerY" secondItem="AtM-bL-7pS" secondAttribute="centerY" id="07n-jt-3rz"/>
<constraint firstItem="2ox-HD-0UT" firstAttribute="leading" secondItem="AtM-bL-7pS" secondAttribute="leadingMargin" id="Koi-9G-bG8"/>
<constraint firstAttribute="trailingMargin" secondItem="e30-w4-5fk" secondAttribute="trailing" id="Wa7-n6-lcl"/>
<constraint firstItem="e30-w4-5fk" firstAttribute="centerY" secondItem="AtM-bL-7pS" secondAttribute="centerY" id="n7R-aQ-FBX"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="0.14999999999999999" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<edgeInsets key="layoutMargins" top="8" left="30" bottom="8" right="30"/>
@@ -894,7 +907,7 @@
<userDefinedRuntimeAttribute type="number" keyPath="style">
<integer key="value" value="3"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="isSelectable" value="YES"/>
<userDefinedRuntimeAttribute type="boolean" keyPath="isSelectable" value="NO"/>
</userDefinedRuntimeAttributes>
</tableViewCell>
</cells>
@@ -912,6 +925,7 @@
<outlet property="backgroundRefreshSwitch" destination="DPu-zD-Als" id="eiG-Hv-Vko"/>
<outlet property="disableAppLimitSwitch" destination="1aa-og-ZXD" id="oVL-Md-yZ8"/>
<outlet property="noIdleTimeoutSwitch" destination="iQA-wm-5ag" id="jHC-js-q0Y"/>
<outlet property="disableResponseCachingSwitch" destination="e30-w4-5fk" id="Duy-Yb-eo1"/>
<outlet property="enforceThreeAppLimitSwitch" destination="Oie-te-KSQ" id="jKn-t1-gyk"/>
<outlet property="versionLabel" destination="bUR-rp-Nw2" id="85I-5R-hqz"/>
</connections>

View File

@@ -74,6 +74,7 @@ extension SettingsViewController
case anisetteServers
case advancedSettings
case responseCaching
}
}
@@ -96,6 +97,7 @@ final class SettingsViewController: UITableViewController
@IBOutlet private var refreshSideJITServer: UILabel!
@IBOutlet private var enforceThreeAppLimitSwitch: UISwitch!
@IBOutlet private var disableResponseCachingSwitch: UISwitch!
@IBOutlet private var versionLabel: UILabel!
@@ -217,6 +219,7 @@ private extension SettingsViewController
self.noIdleTimeoutSwitch.isOn = UserDefaults.standard.isIdleTimeoutDisableEnabled
self.disableAppLimitSwitch.isOn = UserDefaults.standard.isAppLimitDisabled
self.enforceThreeAppLimitSwitch.isOn = !UserDefaults.standard.ignoreActiveAppsLimit
self.disableResponseCachingSwitch.isOn = UserDefaults.standard.responseCachingDisabled
if self.isViewLoaded
{
@@ -400,6 +403,11 @@ private extension SettingsViewController
}
}
@IBAction func toggleDisableResponseCaching(_ sender: UISwitch)
{
UserDefaults.standard.responseCachingDisabled = sender.isOn
}
@IBAction func addRefreshAppsShortcut()
{
guard let shortcut = INShortcut(intent: INInteraction.refreshAllApps().intent) else { return }
@@ -866,7 +874,7 @@ extension SettingsViewController
} else {
ELOG("UIApplication.openSettingsURLString invalid")
}
case .refreshAttempts, .errorLog: break
case .refreshAttempts, .errorLog, .responseCaching: break
}

View File

@@ -76,6 +76,7 @@ public extension UserDefaults
@NSManaged var isCowExploitSupported: Bool
@NSManaged var permissionCheckingDisabled: Bool
@NSManaged var responseCachingDisabled: Bool
class func registerDefaults()
{
@@ -125,5 +126,9 @@ public extension UserDefaults
// Disable ignoreActiveAppsLimit if running iOS version that doesn't support MacDirtyCow.
UserDefaults.standard.ignoreActiveAppsLimit = false
}
#if !BETA
UserDefaults.standard.responseCachingDisabled = false
#endif
}
}