Skip to content

Manic EMU is an all-in-one retro game emulator for iOS. It packs powerful features while keeping a clean, sleek UI and delivering buttery-smooth gameplay.

Swift

Fix iCloud sync crash issue

Daiuno53335b54caa7
diff --git a/.gitmodules b/.gitmodules
index 597188b9..005c9495 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -36,3 +36,8 @@
path = StikJIT
url = https://github.com/StephenDev0/StikJIT.git
ignore = all
+[submodule "Dependencies/SwiftCloudDrive"]
+ path = Dependencies/SwiftCloudDrive
+ url = https://github.com/Daiuno/SwiftCloudDrive.git
+ branch = main
+ ignore = all
diff --git a/Dependencies/SwiftCloudDrive b/Dependencies/SwiftCloudDrive
new file mode 160000
index 00000000..84ef6252
--- /dev/null
+++ b/Dependencies/SwiftCloudDrive
@@ -0,0 +1 @@
+Subproject commit 84ef62522a7c002d018eebe76194f4cbc34dc305
diff --git a/ManicEmu/ManicEmu.xcodeproj/project.pbxproj b/ManicEmu/ManicEmu.xcodeproj/project.pbxproj
index 34fb4de4..80015801 100644
--- a/ManicEmu/ManicEmu.xcodeproj/project.pbxproj
+++ b/ManicEmu/ManicEmu.xcodeproj/project.pbxproj
@@ -32,7 +32,6 @@
3C1B9BAFB4C4403B92AD40D6 /* BlurUIKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5706B0BD2DFDE4570066122E /* BlurUIKit */; };
3CC0A81B407547FBA1CF0693 /* C64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37C004DF500A40988FE64A18 /* C64.swift */; };
3DD4E96091F64806BA370918 /* CollectionViewPagingLayout in Frameworks */ = {isa = PBXBuildFile; productRef = 578E209D2FD1B8CB00A2749A /* CollectionViewPagingLayout */; };
- 3E00CA4429104FD6937382A8 /* SwiftCloudDrive in Frameworks */ = {isa = PBXBuildFile; productRef = 57F0D84A2DE2E7A600760F57 /* SwiftCloudDrive */; };
478A7D3ED65840479AA36B1F /* Libretro.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57BFBE172DD32F7700AABF98 /* Libretro.framework */; };
4C03A073F6DB40669F022100 /* FLASH.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6809D2DE31034EF5B9135498 /* FLASH.swift */; };
54CDF4E1512F4F639EE3CDC2 /* WSC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16B86ECC930242969A108735 /* WSC.swift */; };
@@ -750,7 +749,6 @@
57909543303C7D9100A53656 /* SideMenu in Frameworks */ = {isa = PBXBuildFile; productRef = 578E26D82FD41E1200A2749A /* SideMenu */; };
57909544303C7D9100A53656 /* ColorfulX in Frameworks */ = {isa = PBXBuildFile; productRef = 5726FF452D741F5C00041AD5 /* ColorfulX */; };
57909545303C7D9100A53656 /* RswiftLibrary in Frameworks */ = {isa = PBXBuildFile; productRef = 576060282D24E8BD00A98B0C /* RswiftLibrary */; };
- 57909546303C7D9100A53656 /* SwiftCloudDrive in Frameworks */ = {isa = PBXBuildFile; productRef = 57F0D84A2DE2E7A600760F57 /* SwiftCloudDrive */; };
57909547303C7D9100A53656 /* BetterSegmentedControl in Frameworks */ = {isa = PBXBuildFile; productRef = 57C759142FD42CB70093A2B3 /* BetterSegmentedControl */; };
57909548303C7D9100A53656 /* ProHUD in Frameworks */ = {isa = PBXBuildFile; productRef = 578E20A92FD1C40700A2749A /* ProHUD */; };
57909549303C7D9100A53656 /* DeltaCore in Frameworks */ = {isa = PBXBuildFile; productRef = 578E23DF2FD30F1100A2749A /* DeltaCore */; };
@@ -863,6 +861,9 @@
579DDA0D305ABCBF003AB167 /* WhatsNew-AppStore.strings in Resources */ = {isa = PBXBuildFile; fileRef = 579DDA0A305ABCBF003AB167 /* WhatsNew-AppStore.strings */; };
579DDA4A305ABD8A003AB167 /* WhatsNew-Sideload.strings in Resources */ = {isa = PBXBuildFile; fileRef = 579DDA47305ABD8A003AB167 /* WhatsNew-Sideload.strings */; };
579DDA4B305ABD8A003AB167 /* WhatsNew-Sideload.strings in Resources */ = {isa = PBXBuildFile; fileRef = 579DDA47305ABD8A003AB167 /* WhatsNew-Sideload.strings */; };
+ 579DDAD8305AE990003AB167 /* SwiftCloudDrive in Frameworks */ = {isa = PBXBuildFile; productRef = 579DDAD7305AE990003AB167 /* SwiftCloudDrive */; };
+ 579DDADE305AE9BB003AB167 /* SwiftCloudDrive in Frameworks */ = {isa = PBXBuildFile; productRef = 579DDADD305AE9BB003AB167 /* SwiftCloudDrive */; };
+ 579DDAE0305AE9E5003AB167 /* SwiftCloudDrive in Frameworks */ = {isa = PBXBuildFile; productRef = 579DDADF305AE9E5003AB167 /* SwiftCloudDrive */; };
579E54512FD4237B000F08E7 /* FluentDarkModeKit in Frameworks */ = {isa = PBXBuildFile; productRef = 579E54502FD4237B000F08E7 /* FluentDarkModeKit */; };
57A480CC2E733B83001D4598 /* flycast-jitless.libretro.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 57A480CB2E733B77001D4598 /* flycast-jitless.libretro.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
57A480E72E74030E001D4598 /* CheevosChallengeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57A480E62E740301001D4598 /* CheevosChallengeView.swift */; };
@@ -1512,7 +1513,6 @@
57F0D81A2DE1C2D700760F57 /* GameListStyleCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F0D8192DE1C2C200760F57 /* GameListStyleCollectionViewCell.swift */; };
57F0D83E2DE2C5AE00760F57 /* nestopia.libretro.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 57F0D83C2DE2C59900760F57 /* nestopia.libretro.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
57F0D8422DE2CD8D00760F57 /* NES.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F0D8412DE2CD8B00760F57 /* NES.swift */; };
- 57F0D84B2DE2E7A600760F57 /* SwiftCloudDrive in Frameworks */ = {isa = PBXBuildFile; productRef = 57F0D84A2DE2E7A600760F57 /* SwiftCloudDrive */; };
57F1A9182D7D25B900D0CC93 /* GameInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F1A9172D7D25B600D0CC93 /* GameInfoView.swift */; };
57F1A9252D7D36D200D0CC93 /* GameViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F1A9242D7D36CD00D0CC93 /* GameViewExtensions.swift */; };
57F1A9342D7D6D7D00D0CC93 /* ExternalSceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F1A9332D7D6D7C00D0CC93 /* ExternalSceneDelegate.swift */; };
@@ -6890,9 +6890,9 @@
57909541303C7D9100A53656 /* UniversalDetector in Frameworks */,
57909542303C7D9100A53656 /* Closures in Frameworks */,
57909543303C7D9100A53656 /* SideMenu in Frameworks */,
+ 579DDAE0305AE9E5003AB167 /* SwiftCloudDrive in Frameworks */,
57909544303C7D9100A53656 /* ColorfulX in Frameworks */,
57909545303C7D9100A53656 /* RswiftLibrary in Frameworks */,
- 57909546303C7D9100A53656 /* SwiftCloudDrive in Frameworks */,
57909547303C7D9100A53656 /* BetterSegmentedControl in Frameworks */,
57909548303C7D9100A53656 /* ProHUD in Frameworks */,
57909549303C7D9100A53656 /* DeltaCore in Frameworks */,
@@ -6945,6 +6945,7 @@
3C1B9BAFB4C4403B92AD40D6 /* BlurUIKit in Frameworks */,
CB40A54BC3524226B63A8972 /* DNSPageView in Frameworks */,
1EADD4E491B048A4A3E448B1 /* SMBClient in Frameworks */,
+ 579DDADE305AE9BB003AB167 /* SwiftCloudDrive in Frameworks */,
3DD4E96091F64806BA370918 /* CollectionViewPagingLayout in Frameworks */,
C6A3B47603E14D269F8A697C /* ChromaColorPicker in Frameworks */,
EAE31C39F6FF42DE8F5BA497 /* Schedule in Frameworks */,
@@ -6980,7 +6981,6 @@
851B5B08F99A452A91D3DC9D /* SideMenu in Frameworks */,
568CCBBFAD4A4409BB9E3CCB /* ColorfulX in Frameworks */,
F262CBA4C54F440BBEF25093 /* RswiftLibrary in Frameworks */,
- 3E00CA4429104FD6937382A8 /* SwiftCloudDrive in Frameworks */,
B866FD09ADDF4F39949809EE /* BetterSegmentedControl in Frameworks */,
5832261697984FE3A7919D8A /* ProHUD in Frameworks */,
5742E1CD2FDA9FA10031A726 /* AttributedString in Frameworks */,
@@ -7060,9 +7060,9 @@
57C7596F2FD455AA0093A2B3 /* UniversalDetector in Frameworks */,
578E23202FD288C600A2749A /* Closures in Frameworks */,
578E26D92FD41E1200A2749A /* SideMenu in Frameworks */,
+ 579DDAD8305AE990003AB167 /* SwiftCloudDrive in Frameworks */,
5726FF462D741F5C00041AD5 /* ColorfulX in Frameworks */,
576060292D24E8BD00A98B0C /* RswiftLibrary in Frameworks */,
- 57F0D84B2DE2E7A600760F57 /* SwiftCloudDrive in Frameworks */,
57C759152FD42CB70093A2B3 /* BetterSegmentedControl in Frameworks */,
578E20AA2FD1C40700A2749A /* ProHUD in Frameworks */,
578E23E02FD30F1100A2749A /* DeltaCore in Frameworks */,
@@ -13661,7 +13661,6 @@
571BB9382DA44D6B00830134 /* XCRemoteSwiftPackageReference "SwiftSDL2" */,
575A39CA2DCCFA6B00B28FC2 /* XCRemoteSwiftPackageReference "SwiftSoup" */,
570A27FE2DCF03CF001249C6 /* XCRemoteSwiftPackageReference "PLzmaSDK" */,
- 57F0D8492DE2E7A600760F57 /* XCRemoteSwiftPackageReference "SwiftCloudDrive" */,
5706B0BC2DFDE4570066122E /* XCRemoteSwiftPackageReference "BlurUIKit" */,
57B5923A2FD072C3003C4235 /* XCRemoteSwiftPackageReference "SnapKit" */,
57B5923E2FD07394003C4235 /* XCRemoteSwiftPackageReference "SwifterSwift" */,
@@ -13706,6 +13705,7 @@
57F1D5162FFF962400FC5B2A /* XCLocalSwiftPackageReference "../Dependencies/DeltaCore" */,
576C8C5A3032B57A00AEB08F /* XCLocalSwiftPackageReference "../Dependencies/IceCream" */,
579096CF303F0B4C00A53656 /* XCRemoteSwiftPackageReference "HXPhotoPicker" */,
+ 579DDAD6305AE990003AB167 /* XCLocalSwiftPackageReference "../Dependencies/SwiftCloudDrive" */,
);
productRefGroup = A5A001F024555A5F006E0F0E /* Products */;
projectDirPath = "";
@@ -16518,6 +16518,10 @@
isa = XCLocalSwiftPackageReference;
relativePath = ../Dependencies/ProHUD;
};
+ 579DDAD6305AE990003AB167 /* XCLocalSwiftPackageReference "../Dependencies/SwiftCloudDrive" */ = {
+ isa = XCLocalSwiftPackageReference;
+ relativePath = ../Dependencies/SwiftCloudDrive;
+ };
57ABFAC82FE98443001C1425 /* XCLocalSwiftPackageReference "../Dependencies/CollectionViewPagingLayout" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../Dependencies/CollectionViewPagingLayout;
@@ -16941,14 +16945,6 @@
revision = 9ae5bc2ce2149980884d4612321c3a266d6bf82c;
};
};
- 57F0D8492DE2E7A600760F57 /* XCRemoteSwiftPackageReference "SwiftCloudDrive" */ = {
- isa = XCRemoteSwiftPackageReference;
- repositoryURL = "https://github.com/drewmccormack/SwiftCloudDrive.git";
- requirement = {
- kind = exactVersion;
- version = 1.4.4;
- };
- };
57F632A12D6F17AB007270E8 /* XCRemoteSwiftPackageReference "SMBClient" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/kishikawakatsumi/SMBClient.git";
@@ -17162,6 +17158,20 @@
isa = XCSwiftPackageProductDependency;
productName = ProHUD;
};
+ 579DDAD7305AE990003AB167 /* SwiftCloudDrive */ = {
+ isa = XCSwiftPackageProductDependency;
+ productName = SwiftCloudDrive;
+ };
+ 579DDADD305AE9BB003AB167 /* SwiftCloudDrive */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = 579DDAD6305AE990003AB167 /* XCLocalSwiftPackageReference "../Dependencies/SwiftCloudDrive" */;
+ productName = SwiftCloudDrive;
+ };
+ 579DDADF305AE9E5003AB167 /* SwiftCloudDrive */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = 579DDAD6305AE990003AB167 /* XCLocalSwiftPackageReference "../Dependencies/SwiftCloudDrive" */;
+ productName = SwiftCloudDrive;
+ };
579E54502FD4237B000F08E7 /* FluentDarkModeKit */ = {
isa = XCSwiftPackageProductDependency;
package = 579E544F2FD4237B000F08E7 /* XCRemoteSwiftPackageReference "FluentDarkModeKit" */;
@@ -17300,11 +17310,6 @@
package = 57E48D8F2D8D736B008000A3 /* XCRemoteSwiftPackageReference "ConfettiSwiftUI" */;
productName = ConfettiSwiftUI;
};
- 57F0D84A2DE2E7A600760F57 /* SwiftCloudDrive */ = {
- isa = XCSwiftPackageProductDependency;
- package = 57F0D8492DE2E7A600760F57 /* XCRemoteSwiftPackageReference "SwiftCloudDrive" */;
- productName = SwiftCloudDrive;
- };
57F1D3E12FF1437F00FC5B2A /* KeychainAccess */ = {
isa = XCSwiftPackageProductDependency;
package = 57CDCFBB2FD5D154005BA4C8 /* XCRemoteSwiftPackageReference "KeychainAccess" */;
diff --git a/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index a04e2cc5..05fe49a5 100644
--- a/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -1,5 +1,5 @@
{
- "originHash" : "61d86f378064e763dfc2be709f822f7c0843e1020a59ba89eceea25dcb46265e",
+ "originHash" : "5032f210fe15fb4a7a035a7e3bbd65cfadd94b6e5c55ddc5f5526be889b95aa9",
"pins" : [
{
"identity" : "attributedstring",
@@ -522,15 +522,6 @@
"version" : "1.8.2"
}
},
- {
- "identity" : "swiftclouddrive",
- "kind" : "remoteSourceControl",
- "location" : "https://github.com/drewmccormack/SwiftCloudDrive.git",
- "state" : {
- "revision" : "4f2f38724d6a8724f727c1bc10d9cddd17fbb9e8",
- "version" : "1.4.4"
- }
- },
{
"identity" : "swifter",
"kind" : "remoteSourceControl",
diff --git a/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmuDebug.xcscheme b/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmuDebug.xcscheme
index d844db88..d127904b 100644
--- a/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmuDebug.xcscheme
+++ b/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmuDebug.xcscheme
@@ -31,7 +31,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
- buildConfiguration = "SideloadRelease"
+ buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
diff --git a/ManicEmu/ManicEmu/Resources/ar.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/ar.lproj/Localizable.strings
index f0de2145..5bf76b1a 100644
--- a/ManicEmu/ManicEmu/Resources/ar.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/ar.lproj/Localizable.strings
@@ -1131,3 +1131,9 @@
"ScrollToLastGame" = "التمرير إلى آخر لعبة";
"ScrollToFirstGame" = "التمرير إلى أول لعبة";
"WhatsNew" = "ما الجديد في v%@";
+
+"ICloudROMWiFiOnly" = "مزامنة ROM عبر Wi-Fi فقط";
+"ICloudROMSizeLimit" = "حد حجم ROM";
+"ICloudROMSizeLimitUnlimited" = "بلا حد";
+"ICloudROMSizeLimitDesc" = "تبقى ملفات ROM الأكبر من هذا على هذا الجهاز فقط، حتى لا تملأ صورة قرص كبيرة واحدة مساحة iCloud Drive. حفظ اللعبة والحفظ الفوري والسكين والإعدادات لا تتأثر أبدًا.";
+"ICloudROMTransferLimitDesc" = "ينطبق هذان الحدان على ملفات ROM فقط. يستمر حفظ اللعبة والحفظ الفوري والسكين والإعدادات بالمزامنة عبر أي شبكة وبأي حجم. فتح لعبة ينزّل ROM دائمًا، حتى إذا كان الحد سيمنع المزامنة.";
diff --git a/ManicEmu/ManicEmu/Resources/ca.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/ca.lproj/Localizable.strings
index 6394bbb9..d1e3c3c3 100644
--- a/ManicEmu/ManicEmu/Resources/ca.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/ca.lproj/Localizable.strings
@@ -1160,3 +1160,9 @@ Si voleu millorar la vostra configuració, PlayCase és el complement perfecte p
"ScrollToLastGame" = "Vés a l'últim joc";
"ScrollToFirstGame" = "Vés al primer joc";
"WhatsNew" = "Novetats de la v%@";
+
+"ICloudROMWiFiOnly" = "Sincronitza els ROM només per Wi-Fi";
+"ICloudROMSizeLimit" = "Límit de mida de ROM";
+"ICloudROMSizeLimitUnlimited" = "Sense límit";
+"ICloudROMSizeLimitDesc" = "Els ROM més grans que aquesta mida es queden només en aquest dispositiu, perquè una sola imatge de disc gran no ompli iCloud Drive. Les partides, els estats desats, les skins i la configuració no es veuen afectats.";
+"ICloudROMTransferLimitDesc" = "Aquests dos límits s'apliquen només als fitxers ROM. Les partides, els estats desats, les skins i la configuració continuen sincronitzant-se en qualsevol xarxa i amb qualsevol mida. En obrir un joc sempre es baixa el ROM, encara que un límit n'impedeixi la sincronització.";
diff --git a/ManicEmu/ManicEmu/Resources/cs.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/cs.lproj/Localizable.strings
index bb5a798d..101412ce 100644
--- a/ManicEmu/ManicEmu/Resources/cs.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/cs.lproj/Localizable.strings
@@ -1153,3 +1153,9 @@ Pokud chcete vylepšit své nastavení, PlayCase je perfektním doplňkem tohoto
"ScrollToLastGame" = "Posunout na poslední hru";
"ScrollToFirstGame" = "Posunout na první hru";
"WhatsNew" = "Co je nového ve v%@";
+
+"ICloudROMWiFiOnly" = "Synchronizovat ROM jen přes Wi-Fi";
+"ICloudROMSizeLimit" = "Limit velikosti ROM";
+"ICloudROMSizeLimitUnlimited" = "Bez limitu";
+"ICloudROMSizeLimitDesc" = "ROM větší než tato velikost zůstanou jen na tomto zařízení, aby jediný velký obraz disku nezaplnil iCloud Drive. Uložení her, uložení stavu, skiny a nastavení nejsou nikdy ovlivněny.";
+"ICloudROMTransferLimitDesc" = "Tyto dva limity platí jen pro soubory ROM. Uložení her, uložení stavu, skiny a nastavení se dál synchronizují v jakékoli síti a při jakékoli velikosti. Otevření hry vždy stáhne ROM, i když by limit synchronizaci jinak zadržel.";
diff --git a/ManicEmu/ManicEmu/Resources/da.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/da.lproj/Localizable.strings
index 5bda789c..24e25f04 100644
--- a/ManicEmu/ManicEmu/Resources/da.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/da.lproj/Localizable.strings
@@ -1156,3 +1156,9 @@ Hvis du vil forbedre dit setup, er PlayCase et perfekt match til dette skin.";
"ScrollToLastGame" = "Rul til sidste spil";
"ScrollToFirstGame" = "Rul til første spil";
"WhatsNew" = "Nyheder i v%@";
+
+"ICloudROMWiFiOnly" = "Synkroniser ROM kun via Wi-Fi";
+"ICloudROMSizeLimit" = "Størrelsesgrænse for ROM";
+"ICloudROMSizeLimitUnlimited" = "Ingen grænse";
+"ICloudROMSizeLimitDesc" = "ROM-filer større end dette bliver kun på denne enhed, så et enkelt stort diskimage ikke fylder iCloud Drive. Gemte spil, savestates, skins og indstillinger påvirkes aldrig.";
+"ICloudROMTransferLimitDesc" = "Disse to grænser gælder kun for ROM-filer. Gemte spil, savestates, skins og indstillinger bliver ved med at synkronisere over alle netværk og uanset størrelse. Når du åbner et spil, downloades ROM-filen altid, selv hvis en grænse ellers ville forhindre synkronisering.";
diff --git a/ManicEmu/ManicEmu/Resources/de.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/de.lproj/Localizable.strings
index 7b913d4b..012b5b9d 100644
--- a/ManicEmu/ManicEmu/Resources/de.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/de.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Wenn Sie Ihr Setup verbessern möchten, ist PlayCase die perfekte Ergänzung zu
"ScrollToLastGame" = "Zum letzten Spiel scrollen";
"ScrollToFirstGame" = "Zum ersten Spiel scrollen";
"WhatsNew" = "Neuigkeiten in v%@";
+
+"ICloudROMWiFiOnly" = "ROMs nur über Wi-Fi synchronisieren";
+"ICloudROMSizeLimit" = "ROM-Größenlimit";
+"ICloudROMSizeLimitUnlimited" = "Kein Limit";
+"ICloudROMSizeLimitDesc" = "ROMs, die größer sind als dieser Wert, bleiben nur auf diesem Gerät, damit ein einzelnes großes Disc-Image iCloud Drive nicht füllt. Spielstände, Savestates, Skins und Einstellungen sind nie betroffen.";
+"ICloudROMTransferLimitDesc" = "Diese beiden Limits gelten nur für ROM-Dateien. Spielstände, Savestates, Skins und Einstellungen werden weiterhin über jedes Netz und in jeder Größe synchronisiert. Beim Öffnen eines Spiels wird die ROM stets heruntergeladen, auch wenn ein Limit die Synchronisierung sonst verhindern würde.";
diff --git a/ManicEmu/ManicEmu/Resources/el.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/el.lproj/Localizable.strings
index 220b1e0c..16eb3803 100644
--- a/ManicEmu/ManicEmu/Resources/el.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/el.lproj/Localizable.strings
@@ -1161,3 +1161,9 @@
"ScrollToLastGame" = "Κύλιση στο Τελευταίο Παιχνίδι";
"ScrollToFirstGame" = "Κύλιση στο Πρώτο Παιχνίδι";
"WhatsNew" = "Τι Νέο υπάρχει στο v%@";
+
+"ICloudROMWiFiOnly" = "Συγχρονισμός ROM μόνο μέσω Wi-Fi";
+"ICloudROMSizeLimit" = "Όριο μεγέθους ROM";
+"ICloudROMSizeLimitUnlimited" = "Χωρίς όριο";
+"ICloudROMSizeLimitDesc" = "Τα ROM μεγαλύτερα από αυτό το μέγεθος μένουν μόνο σε αυτή τη συσκευή, ώστε μία μεγάλη εικόνα δίσκου να μην γεμίζει το iCloud Drive. Τα αποθηκευμένα παιχνίδια, οι αποθηκευμένες καταστάσεις, τα skin και οι ρυθμίσεις δεν επηρεάζονται ποτέ.";
+"ICloudROMTransferLimitDesc" = "Αυτά τα δύο όρια ισχύουν μόνο για αρχεία ROM. Τα αποθηκευμένα παιχνίδια, οι αποθηκευμένες καταστάσεις, τα skin και οι ρυθμίσεις συνεχίζουν να συγχρονίζονται σε οποιοδήποτε δίκτυο και οποιοδήποτε μέγεθος. Το άνοιγμα ενός παιχνιδιού πάντα κατεβάζει το ROM, ακόμη και αν ένα όριο θα εμπόδιζε τον συγχρονισμό.";
diff --git a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings
index 0df67c45..42920058 100644
--- a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings
@@ -1141,6 +1141,11 @@ Press the controller button to complete mapping...";
"ICloudRepairSyncResult" = "Repair finished. Uploaded %d, downloaded %d.";
"ICloudRepairSyncResultPending" = "Repair finished. Uploaded %d, downloaded %d. %d files will retry later.";
"ICloudROMStillSyncing" = "This ROM is still downloading from iCloud. Try again in a moment.";
+"ICloudROMWiFiOnly" = "Sync ROMs on Wi-Fi Only";
+"ICloudROMSizeLimit" = "ROM Size Limit";
+"ICloudROMSizeLimitUnlimited" = "No Limit";
+"ICloudROMSizeLimitDesc" = "ROMs larger than this are kept on this device only, so a single large disc image does not fill up iCloud Drive. Saves, save states, skins, and settings are never affected.";
+"ICloudROMTransferLimitDesc" = "These two limits apply to ROM files only. Saves, save states, skins, and settings keep syncing over any network and at any size. Opening a game always downloads its ROM, even when a limit would otherwise keep it from syncing.";
"WSwanRotateDisplay" = "Rotate Display";
"NDSLidToggle" = "Toggle Lid";
diff --git a/ManicEmu/ManicEmu/Resources/es-419.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/es-419.lproj/Localizable.strings
index 8ccd7d99..68efd18a 100644
--- a/ManicEmu/ManicEmu/Resources/es-419.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/es-419.lproj/Localizable.strings
@@ -1158,3 +1158,9 @@ Si quieres mejorar tu experiencia, PlayCase combina perfecto con esta funda.";
"ScrollToLastGame" = "Ir al último juego";
"ScrollToFirstGame" = "Ir al primer juego";
"WhatsNew" = "Novedades de la v%@";
+
+"ICloudROMWiFiOnly" = "Sincronizar ROM solo por Wi-Fi";
+"ICloudROMSizeLimit" = "Límite de tamaño de ROM";
+"ICloudROMSizeLimitUnlimited" = "Sin límite";
+"ICloudROMSizeLimitDesc" = "Los ROM más grandes que este tamaño se quedan solo en este dispositivo, para que una sola imagen de disco grande no llene iCloud Drive. Los guardados, los estados de guardado, las skins y los ajustes no se ven afectados.";
+"ICloudROMTransferLimitDesc" = "Estos dos límites se aplican solo a los archivos ROM. Los guardados, los estados de guardado, las skins y los ajustes siguen sincronizándose en cualquier red y con cualquier tamaño. Al abrir un juego siempre se descarga su ROM, aunque un límite impida sincronizarlo.";
diff --git a/ManicEmu/ManicEmu/Resources/es.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/es.lproj/Localizable.strings
index 3e2ea039..e452770f 100644
--- a/ManicEmu/ManicEmu/Resources/es.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/es.lproj/Localizable.strings
@@ -1133,3 +1133,9 @@ Si quieres mejorar tu configuración, PlayCase es el complemento perfecto para e
"ScrollToLastGame" = "Ir al último juego";
"ScrollToFirstGame" = "Ir al primer juego";
"WhatsNew" = "Novedades de la v%@";
+
+"ICloudROMWiFiOnly" = "Sincronizar ROM solo por Wi-Fi";
+"ICloudROMSizeLimit" = "Límite de tamaño de ROM";
+"ICloudROMSizeLimitUnlimited" = "Sin límite";
+"ICloudROMSizeLimitDesc" = "Los ROM más grandes que este tamaño se quedan solo en este dispositivo, para que una sola imagen de disco grande no llene iCloud Drive. Las partidas, los estados de guardado, las skins y los ajustes no se ven afectados.";
+"ICloudROMTransferLimitDesc" = "Estos dos límites se aplican solo a los archivos ROM. Las partidas, los estados de guardado, las skins y los ajustes siguen sincronizándose en cualquier red y con cualquier tamaño. Al abrir un juego siempre se descarga su ROM, aunque un límite impida sincronizarlo.";
diff --git a/ManicEmu/ManicEmu/Resources/fi.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/fi.lproj/Localizable.strings
index 8c9efc2a..35192ead 100644
--- a/ManicEmu/ManicEmu/Resources/fi.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/fi.lproj/Localizable.strings
@@ -1161,3 +1161,9 @@ Jos haluat parantaa kokoonpanoasi, PlayCase on täydellinen lisä tälle skinill
"ScrollToLastGame" = "Vieritä viimeiseen peliin";
"ScrollToFirstGame" = "Vieritä ensimmäiseen peliin";
"WhatsNew" = "Uutta versiossa v%@";
+
+"ICloudROMWiFiOnly" = "Synkronoi ROM-tiedostot vain Wi-Fin kautta";
+"ICloudROMSizeLimit" = "ROM-kokorajoitus";
+"ICloudROMSizeLimitUnlimited" = "Ei rajaa";
+"ICloudROMSizeLimitDesc" = "Tätä suuremmat ROM-tiedostot jäävät vain tälle laitteelle, jotta yksi suuri levykuva ei täytä iCloud Drivea. Pelitallennuksiin, pikatallennuksiin, skineihin ja asetuksiin tällä ei ole vaikutusta.";
+"ICloudROMTransferLimitDesc" = "Nämä kaksi rajoitusta koskevat vain ROM-tiedostoja. Pelitallennukset, pikatallennukset, skinit ja asetukset synkronoituvat edelleen kaikissa verkoissa ja kaikenkokoisina. Pelin avaaminen lataa ROM-tiedoston aina, vaikka rajoitus muuten estäisi synkronoinnin.";
diff --git a/ManicEmu/ManicEmu/Resources/fr-CA.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/fr-CA.lproj/Localizable.strings
index fdee655a..3f434b87 100644
--- a/ManicEmu/ManicEmu/Resources/fr-CA.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/fr-CA.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Si vous voulez améliorer votre installation, PlayCase est le complément parfai
"ScrollToLastGame" = "Aller au dernier jeu";
"ScrollToFirstGame" = "Aller au premier jeu";
"WhatsNew" = "Nouveautés de la v%@";
+
+"ICloudROMWiFiOnly" = "Synchroniser les ROM en Wi-Fi seulement";
+"ICloudROMSizeLimit" = "Limite de taille des ROM";
+"ICloudROMSizeLimitUnlimited" = "Aucune limite";
+"ICloudROMSizeLimitDesc" = "Les ROM plus volumineux que cette taille restent uniquement sur cet appareil, afin qu'une seule grande image disque ne remplisse pas iCloud Drive. Les sauvegardes, sauvegardes instantanées, skins et paramètres ne sont jamais touchés.";
+"ICloudROMTransferLimitDesc" = "Ces deux limites s'appliquent uniquement aux fichiers ROM. Les sauvegardes, sauvegardes instantanées, skins et paramètres continuent de se synchroniser sur n'importe quel réseau et peu importe leur taille. Ouvrir un jeu télécharge toujours son ROM, même si une limite l'empêcherait autrement de se synchroniser.";
diff --git a/ManicEmu/ManicEmu/Resources/fr.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/fr.lproj/Localizable.strings
index 86ef6d1e..7756d7ce 100644
--- a/ManicEmu/ManicEmu/Resources/fr.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/fr.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Si vous souhaitez améliorer votre configuration, PlayCase est le complément id
"ScrollToLastGame" = "Aller au dernier jeu";
"ScrollToFirstGame" = "Aller au premier jeu";
"WhatsNew" = "Nouveautés de la v%@";
+
+"ICloudROMWiFiOnly" = "Synchroniser les ROM uniquement en Wi-Fi";
+"ICloudROMSizeLimit" = "Limite de taille des ROM";
+"ICloudROMSizeLimitUnlimited" = "Aucune limite";
+"ICloudROMSizeLimitDesc" = "Les ROM plus volumineux que cette taille restent uniquement sur cet appareil, afin qu'une seule grande image disque ne remplisse pas iCloud Drive. Les sauvegardes, sauvegardes instantanées, skins et paramètres ne sont jamais affectés.";
+"ICloudROMTransferLimitDesc" = "Ces deux limites s'appliquent uniquement aux fichiers ROM. Les sauvegardes, sauvegardes instantanées, skins et paramètres continuent de se synchroniser sur n'importe quel réseau et quelle que soit leur taille. Ouvrir un jeu télécharge toujours son ROM, même si une limite l'empêcherait autrement de se synchroniser.";
diff --git a/ManicEmu/ManicEmu/Resources/he.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/he.lproj/Localizable.strings
index f3be1b3f..e6b808ac 100644
--- a/ManicEmu/ManicEmu/Resources/he.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/he.lproj/Localizable.strings
@@ -1161,3 +1161,9 @@ PlayCase מתמקדת במעטפות iPhone איכותיות, המיוצרות
"ScrollToLastGame" = "גלילה למשחק האחרון";
"ScrollToFirstGame" = "גלילה למשחק הראשון";
"WhatsNew" = "מה חדש בגרסה v%@";
+
+"ICloudROMWiFiOnly" = "סנכרון ROM ב-Wi-Fi בלבד";
+"ICloudROMSizeLimit" = "מגבלת גודל ROM";
+"ICloudROMSizeLimitUnlimited" = "ללא הגבלה";
+"ICloudROMSizeLimitDesc" = "קבצי ROM גדולים מזה נשארים במכשיר זה בלבד, כדי שתמונת דיסק גדולה אחת לא תמלא את iCloud Drive. שמירות משחק, שמירות מיידיות, skin והגדרות אינם מושפעים.";
+"ICloudROMTransferLimitDesc" = "שתי המגבלות האלה חלות על קבצי ROM בלבד. שמירות משחק, שמירות מיידיות, skin והגדרות ממשיכים להסתנכרן בכל רשת ובכל גודל. פתיחת משחק תמיד מורידה את ה-ROM, גם אם מגבלה הייתה מונעת סנכרון.";
diff --git a/ManicEmu/ManicEmu/Resources/hi.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/hi.lproj/Localizable.strings
index 8f5aa068..d5c8022d 100644
--- a/ManicEmu/ManicEmu/Resources/hi.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/hi.lproj/Localizable.strings
@@ -1160,3 +1160,9 @@ PlayCase हाई-क्वालिटी iPhone केसों पर के
"ScrollToLastGame" = "आखिरी गेम पर स्क्रोल करें";
"ScrollToFirstGame" = "पहले गेम पर स्क्रोल करें";
"WhatsNew" = "v%@ में क्या नया है";
+
+"ICloudROMWiFiOnly" = "केवल Wi-Fi पर ROM सिंक करें";
+"ICloudROMSizeLimit" = "ROM आकार सीमा";
+"ICloudROMSizeLimitUnlimited" = "कोई सीमा नहीं";
+"ICloudROMSizeLimitDesc" = "इससे बड़े ROM सिर्फ़ इस डिवाइस पर रहते हैं, ताकि एक बड़ी डिस्क इमेज iCloud Drive न भर दे। गेम सेव, सेव स्टेट्स, स्किन और सेटिंग्स प्रभावित नहीं होते।";
+"ICloudROMTransferLimitDesc" = "ये दो सीमाएँ सिर्फ़ ROM फ़ाइलों पर लागू होती हैं। गेम सेव, सेव स्टेट्स, स्किन और सेटिंग्स किसी भी नेटवर्क और किसी भी आकार पर सिंक होते रहते हैं। गेम खोलने पर उसका ROM हमेशा डाउनलोड होता है, भले ही सीमा उसे सिंक होने से रोकती।";
diff --git a/ManicEmu/ManicEmu/Resources/hr.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/hr.lproj/Localizable.strings
index 12b268d9..58724bd9 100644
--- a/ManicEmu/ManicEmu/Resources/hr.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/hr.lproj/Localizable.strings
@@ -1158,3 +1158,9 @@ Ako želite unaprijediti svoju postavu, PlayCase je savršen dodatak ovom skinu.
"ScrollToLastGame" = "Pomakni do zadnje igre";
"ScrollToFirstGame" = "Pomakni do prve igre";
"WhatsNew" = "Što je novo u v%@";
+
+"ICloudROMWiFiOnly" = "Sinkroniziraj ROM-ove samo putem Wi-Fi mreže";
+"ICloudROMSizeLimit" = "Ograničenje veličine ROM-a";
+"ICloudROMSizeLimitUnlimited" = "Bez ograničenja";
+"ICloudROMSizeLimitDesc" = "ROM-ovi veći od ove veličine ostaju samo na ovom uređaju, da jedna velika slika diska ne popuni iCloud Drive. Spremanja igre, save stateovi, skinovi i postavke nikad nisu zahvaćeni.";
+"ICloudROMTransferLimitDesc" = "Ova dva ograničenja vrijede samo za ROM datoteke. Spremanja igre, save stateovi, skinovi i postavke i dalje se sinkroniziraju na bilo kojoj mreži i bilo koje veličine. Otvaranje igre uvijek preuzima ROM, čak i kad bi ograničenje inače spriječilo sinkronizaciju.";
diff --git a/ManicEmu/ManicEmu/Resources/hu.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/hu.lproj/Localizable.strings
index 40e4111d..e782306b 100644
--- a/ManicEmu/ManicEmu/Resources/hu.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/hu.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Ha fejleszteni szeretnéd a beállításod, a PlayCase tökéletes kiegészítő
"ScrollToLastGame" = "Görgetés az utolsó játékhoz";
"ScrollToFirstGame" = "Görgetés az első játékhoz";
"WhatsNew" = "Újdonságok a v%@ verzióban";
+
+"ICloudROMWiFiOnly" = "ROM-ok szinkronizálása csak Wi-Fi-n";
+"ICloudROMSizeLimit" = "ROM méretkorlát";
+"ICloudROMSizeLimitUnlimited" = "Nincs korlát";
+"ICloudROMSizeLimitDesc" = "Az ennél nagyobb ROM-ok csak ezen az eszközön maradnak, hogy egyetlen nagy lemezkép ne töltse fel az iCloud Drive-ot. A játékmentések, azonnali mentések, skinek és beállítások soha nem érintettek.";
+"ICloudROMTransferLimitDesc" = "Ez a két korlát csak a ROM-fájlokra vonatkozik. A játékmentések, azonnali mentések, skinek és beállítások bármely hálózaton és bármilyen méretben tovább szinkronizálódnak. A játék megnyitásakor a ROM mindig letöltődik, még akkor is, ha a korlát egyébként megakadályozná a szinkronizálást.";
diff --git a/ManicEmu/ManicEmu/Resources/id.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/id.lproj/Localizable.strings
index 2ca71bd2..9d6a8d33 100644
--- a/ManicEmu/ManicEmu/Resources/id.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/id.lproj/Localizable.strings
@@ -1151,3 +1151,9 @@ Jika Anda ingin meningkatkan setup Anda, PlayCase adalah pasangan sempurna untuk
"ScrollToLastGame" = "Gulir ke Permainan Terakhir";
"ScrollToFirstGame" = "Gulir ke Permainan Pertama";
"WhatsNew" = "Yang Baru di v%@";
+
+"ICloudROMWiFiOnly" = "Sinkronkan ROM hanya lewat Wi-Fi";
+"ICloudROMSizeLimit" = "Batas ukuran ROM";
+"ICloudROMSizeLimitUnlimited" = "Tanpa batas";
+"ICloudROMSizeLimitDesc" = "ROM yang lebih besar dari ini hanya disimpan di perangkat ini, agar satu image cakram besar tidak memenuhi iCloud Drive. Simpanan, simpanan instan, skin, dan pengaturan tidak pernah terpengaruh.";
+"ICloudROMTransferLimitDesc" = "Kedua batas ini hanya berlaku untuk file ROM. Simpanan, simpanan instan, skin, dan pengaturan tetap tersinkron di jaringan apa pun dan ukuran apa pun. Membuka game selalu mengunduh ROM-nya, meski batas seharusnya menahan sinkronisasi.";
diff --git a/ManicEmu/ManicEmu/Resources/it.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/it.lproj/Localizable.strings
index 41605c70..9c7e58fb 100644
--- a/ManicEmu/ManicEmu/Resources/it.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/it.lproj/Localizable.strings
@@ -1162,3 +1162,9 @@ Se vuoi migliorare il tuo setup, PlayCase è l’abbinamento perfetto per questa
"ScrollToLastGame" = "Vai all'ultimo gioco";
"ScrollToFirstGame" = "Vai al primo gioco";
"WhatsNew" = "Novità della v%@";
+
+"ICloudROMWiFiOnly" = "Sincronizza i ROM solo via Wi-Fi";
+"ICloudROMSizeLimit" = "Limite dimensione ROM";
+"ICloudROMSizeLimitUnlimited" = "Nessun limite";
+"ICloudROMSizeLimitDesc" = "I ROM più grandi di questa soglia restano solo su questo dispositivo, così una singola immagine disco di grandi dimensioni non riempie iCloud Drive. Salvataggi, save state, skin e impostazioni non vengono mai interessati.";
+"ICloudROMTransferLimitDesc" = "Questi due limiti si applicano solo ai file ROM. Salvataggi, save state, skin e impostazioni continuano a sincronizzarsi su qualsiasi rete e con qualsiasi dimensione. Aprendo un gioco il ROM viene sempre scaricato, anche se un limite ne impedirebbe altrimenti la sincronizzazione.";
diff --git a/ManicEmu/ManicEmu/Resources/ja.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/ja.lproj/Localizable.strings
index 986a875b..0e760ed4 100644
--- a/ManicEmu/ManicEmu/Resources/ja.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/ja.lproj/Localizable.strings
@@ -1154,3 +1154,9 @@ PlayCaseは、アクセサリーやスキンとの互換性を考慮して作ら
"ScrollToLastGame" = "最後のゲームへスクロール";
"ScrollToFirstGame" = "最初のゲームへスクロール";
"WhatsNew" = "v%@の新機能";
+
+"ICloudROMWiFiOnly" = "Wi-Fi のみで ROM を同期";
+"ICloudROMSizeLimit" = "ROMサイズ制限";
+"ICloudROMSizeLimitUnlimited" = "制限なし";
+"ICloudROMSizeLimitDesc" = "このサイズを超える ROM はこのデバイスにのみ保持され、大きなディスクイメージ 1 本で iCloud Drive がいっぱいになるのを防ぎます。セーブデータ、セーブステート、スキン、設定には影響しません。";
+"ICloudROMTransferLimitDesc" = "この 2 つの制限は ROM ファイルにのみ適用されます。セーブデータ、セーブステート、スキン、設定は、ネットワークの種類やサイズに関係なく同期を続けます。ゲームを開くと、制限で同期が止まっていても ROM は必ずダウンロードされます。";
diff --git a/ManicEmu/ManicEmu/Resources/ko.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/ko.lproj/Localizable.strings
index 1a02c6af..b6ad6b07 100644
--- a/ManicEmu/ManicEmu/Resources/ko.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/ko.lproj/Localizable.strings
@@ -1162,3 +1162,9 @@ PlayCase는 액세서리 및 스킨 호환성을 고려하여 제작된 고품
"ScrollToLastGame" = "마지막 게임으로 스크롤";
"ScrollToFirstGame" = "첫 게임으로 스크롤";
"WhatsNew" = "v%@의 새로운 기능";
+
+"ICloudROMWiFiOnly" = "Wi-Fi에서만 ROM 동기화";
+"ICloudROMSizeLimit" = "ROM 크기 제한";
+"ICloudROMSizeLimitUnlimited" = "제한 없음";
+"ICloudROMSizeLimitDesc" = "이 크기보다 큰 ROM은 이 기기에만 보관되어, 용량이 큰 디스크 이미지 하나가 iCloud Drive를 채우지 않습니다. 게임 세이브, 세이브 스테이트, 스킨, 설정에는 영향을 주지 않습니다.";
+"ICloudROMTransferLimitDesc" = "이 두 제한은 ROM 파일에만 적용됩니다. 게임 세이브, 세이브 스테이트, 스킨, 설정은 네트워크 종류와 크기에 관계없이 계속 동기화됩니다. 게임을 열면 제한 때문에 동기화되지 않았더라도 ROM을 항상 다운로드합니다.";
diff --git a/ManicEmu/ManicEmu/Resources/ms.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/ms.lproj/Localizable.strings
index 52630929..001632e4 100644
--- a/ManicEmu/ManicEmu/Resources/ms.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/ms.lproj/Localizable.strings
@@ -1132,3 +1132,9 @@ Jika anda ingin meningkatkan persediaan anda, PlayCase adalah padanan sempurna u
"ScrollToLastGame" = "Tatal ke Permainan Terakhir";
"ScrollToFirstGame" = "Tatal ke Permainan Pertama";
"WhatsNew" = "Yang Baharu dalam v%@";
+
+"ICloudROMWiFiOnly" = "Sync ROM melalui Wi-Fi sahaja";
+"ICloudROMSizeLimit" = "Had saiz ROM";
+"ICloudROMSizeLimitUnlimited" = "Tiada had";
+"ICloudROMSizeLimitDesc" = "ROM lebih besar daripada ini kekal pada peranti ini sahaja, supaya satu imej cakera besar tidak memenuhi iCloud Drive. Simpanan, simpanan segera, kulit dan tetapan tidak terjejas.";
+"ICloudROMTransferLimitDesc" = "Kedua-dua had ini hanya untuk fail ROM. Simpanan, simpanan segera, kulit dan tetapan terus disegerakkan pada mana-mana rangkaian dan saiz. Membuka permainan sentiasa memuat turun ROM, walaupun had sepatutnya menahan sync.";
diff --git a/ManicEmu/ManicEmu/Resources/nb.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/nb.lproj/Localizable.strings
index 7726e126..5743be29 100644
--- a/ManicEmu/ManicEmu/Resources/nb.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/nb.lproj/Localizable.strings
@@ -1150,3 +1150,9 @@ Hvis du vil forbedre oppsettet ditt, er PlayCase et perfekt tilbehør til dette
"ScrollToLastGame" = "Rull til siste spill";
"ScrollToFirstGame" = "Rull til første spill";
"WhatsNew" = "Nyheter i v%@";
+
+"ICloudROMWiFiOnly" = "Synkroniser ROM-er bare over Wi-Fi";
+"ICloudROMSizeLimit" = "ROM-størrelsesgrense";
+"ICloudROMSizeLimitUnlimited" = "Ingen grense";
+"ICloudROMSizeLimitDesc" = "ROM-filer større enn dette blir bare på denne enheten, slik at ett stort plateavtrykk ikke fyller iCloud Drive. Lagring, savestates, skins og innstillinger påvirkes aldri.";
+"ICloudROMTransferLimitDesc" = "Disse to grensene gjelder bare ROM-filer. Lagring, savestates, skins og innstillinger fortsetter å synkroniseres over alle nettverk og uansett størrelse. Når du åpner et spill, lastes ROM-filen alltid ned, selv om en grense ellers ville hindret synkronisering.";
diff --git a/ManicEmu/ManicEmu/Resources/nl.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/nl.lproj/Localizable.strings
index 305e42c6..cd5e7909 100644
--- a/ManicEmu/ManicEmu/Resources/nl.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/nl.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Als je je setup naar een hoger niveau wilt tillen, is PlayCase de perfecte match
"ScrollToLastGame" = "Scroll naar laatste game";
"ScrollToFirstGame" = "Scroll naar eerste game";
"WhatsNew" = "Wat is er nieuw in v%@";
+
+"ICloudROMWiFiOnly" = "ROM's alleen via Wi-Fi synchroniseren";
+"ICloudROMSizeLimit" = "ROM-groottebeperking";
+"ICloudROMSizeLimitUnlimited" = "Geen limiet";
+"ICloudROMSizeLimitDesc" = "ROM's groter dan dit blijven alleen op dit apparaat, zodat één groot schijfimage iCloud Drive niet volloopt. Gameopslag, savestates, skins en instellingen worden nooit beïnvloed.";
+"ICloudROMTransferLimitDesc" = "Deze twee limieten gelden alleen voor ROM-bestanden. Gameopslag, savestates, skins en instellingen blijven synchroniseren via elk netwerk en bij elke grootte. Als je een game opent, wordt de ROM altijd gedownload, ook als een limiet de synchronisatie anders zou tegenhouden.";
diff --git a/ManicEmu/ManicEmu/Resources/pl.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/pl.lproj/Localizable.strings
index 119c9728..0653a968 100644
--- a/ManicEmu/ManicEmu/Resources/pl.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/pl.lproj/Localizable.strings
@@ -1132,3 +1132,9 @@ Jeśli chcesz ulepszyć swoją konfigurację, PlayCase jest idealnym uzupełnien
"ScrollToLastGame" = "Przewiń do ostatniej gry";
"ScrollToFirstGame" = "Przewiń do pierwszej gry";
"WhatsNew" = "Co nowego w v%@";
+
+"ICloudROMWiFiOnly" = "Synchronizuj ROM-y tylko przez Wi-Fi";
+"ICloudROMSizeLimit" = "Limit rozmiaru ROM";
+"ICloudROMSizeLimitUnlimited" = "Bez limitu";
+"ICloudROMSizeLimitDesc" = "ROM-y większe niż ten rozmiar zostają tylko na tym urządzeniu, żeby pojedynczy duży obraz płyty nie zapełnił iCloud Drive. Zapisy gry, savestate’y, skóry i ustawienia nie są nigdy naruszane.";
+"ICloudROMTransferLimitDesc" = "Te dwa limity dotyczą tylko plików ROM. Zapisy gry, savestate’y, skóry i ustawienia nadal synchronizują się w dowolnej sieci i przy dowolnym rozmiarze. Otwarcie gry zawsze pobiera ROM, nawet gdy limit inaczej by to wstrzymał.";
diff --git a/ManicEmu/ManicEmu/Resources/pt-BR.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/pt-BR.lproj/Localizable.strings
index fced03d3..427df411 100644
--- a/ManicEmu/ManicEmu/Resources/pt-BR.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/pt-BR.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Se você deseja aprimorar sua configuração, a PlayCase é o complemento perfei
"ScrollToLastGame" = "Ir ao último jogo";
"ScrollToFirstGame" = "Ir ao primeiro jogo";
"WhatsNew" = "Novidades da v%@";
+
+"ICloudROMWiFiOnly" = "Sincronizar ROMs só no Wi-Fi";
+"ICloudROMSizeLimit" = "Limite de tamanho de ROM";
+"ICloudROMSizeLimitUnlimited" = "Sem limite";
+"ICloudROMSizeLimitDesc" = "ROMs maiores que isso ficam só neste dispositivo, para que uma única imagem de disco grande não encha o iCloud Drive. Saves, save states, skins e configurações nunca são afetados.";
+"ICloudROMTransferLimitDesc" = "Esses dois limites valem só para arquivos ROM. Saves, save states, skins e configurações continuam sincronizando em qualquer rede e em qualquer tamanho. Abrir um jogo sempre baixa o ROM, mesmo quando um limite impediria a sincronização.";
diff --git a/ManicEmu/ManicEmu/Resources/pt-PT.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/pt-PT.lproj/Localizable.strings
index c3524965..739dd3dc 100644
--- a/ManicEmu/ManicEmu/Resources/pt-PT.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/pt-PT.lproj/Localizable.strings
@@ -1160,3 +1160,9 @@ Se pretende melhorar a sua configuração, a PlayCase é o complemento perfeito
"ScrollToLastGame" = "Ir para o último jogo";
"ScrollToFirstGame" = "Ir para o primeiro jogo";
"WhatsNew" = "Novidades da v%@";
+
+"ICloudROMWiFiOnly" = "Sincronizar ROM apenas por Wi-Fi";
+"ICloudROMSizeLimit" = "Limite de tamanho de ROM";
+"ICloudROMSizeLimitUnlimited" = "Sem limite";
+"ICloudROMSizeLimitDesc" = "Os ROM maiores do que isto ficam apenas neste dispositivo, para que uma única imagem de disco grande não encha o iCloud Drive. Os saves, save states, skins e definições nunca são afetados.";
+"ICloudROMTransferLimitDesc" = "Estes dois limites aplicam-se apenas a ficheiros ROM. Os saves, save states, skins e definições continuam a sincronizar em qualquer rede e com qualquer tamanho. Ao abrir um jogo, o ROM é sempre descarregado, mesmo que um limite impedisse a sincronização.";
diff --git a/ManicEmu/ManicEmu/Resources/ro.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/ro.lproj/Localizable.strings
index f3651de1..7f163053 100644
--- a/ManicEmu/ManicEmu/Resources/ro.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/ro.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Dacă vrei să îți îmbunătățești setup-ul, PlayCase este potrivirea perfe
"ScrollToLastGame" = "Mergi la ultimul joc";
"ScrollToFirstGame" = "Mergi la primul joc";
"WhatsNew" = "Noutăți în v%@";
+
+"ICloudROMWiFiOnly" = "Sincronizează ROM-urile doar prin Wi-Fi";
+"ICloudROMSizeLimit" = "Limită de dimensiune ROM";
+"ICloudROMSizeLimitUnlimited" = "Fără limită";
+"ICloudROMSizeLimitDesc" = "ROM-urile mai mari decât această dimensiune rămân doar pe acest dispozitiv, ca o singură imagine de disc mare să nu umple iCloud Drive. Salvările de joc, salvările instant, skinurile și setările nu sunt niciodată afectate.";
+"ICloudROMTransferLimitDesc" = "Aceste două limite se aplică doar fișierelor ROM. Salvările de joc, salvările instant, skinurile și setările continuă să se sincronizeze pe orice rețea și la orice dimensiune. La deschiderea unui joc, ROM-ul este descărcat întotdeauna, chiar dacă o limită l-ar împiedica altfel să se sincronizeze.";
diff --git a/ManicEmu/ManicEmu/Resources/ru.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/ru.lproj/Localizable.strings
index 4e02ac2e..8b0a88ec 100644
--- a/ManicEmu/ManicEmu/Resources/ru.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/ru.lproj/Localizable.strings
@@ -1153,3 +1153,9 @@ PlayCase специализируется на высококачественн
"ScrollToLastGame" = "Прокрутить к последней игре";
"ScrollToFirstGame" = "Прокрутить к первой игре";
"WhatsNew" = "Что нового в v%@";
+
+"ICloudROMWiFiOnly" = "Синхронизировать ROM только по Wi-Fi";
+"ICloudROMSizeLimit" = "Ограничение размера ROM";
+"ICloudROMSizeLimitUnlimited" = "Без ограничений";
+"ICloudROMSizeLimitDesc" = "ROM больше этого размера остаются только на этом устройстве, чтобы один крупный образ диска не заполнил iCloud Drive. Сохранения, сейв-стейты, скины и настройки не затрагиваются.";
+"ICloudROMTransferLimitDesc" = "Эти два ограничения действуют только на файлы ROM. Сохранения, сейв-стейты, скины и настройки продолжают синхронизироваться в любой сети и при любом размере. При открытии игры ROM всегда загружается, даже если ограничение иначе не дало бы ему синхронизироваться.";
diff --git a/ManicEmu/ManicEmu/Resources/sk.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/sk.lproj/Localizable.strings
index 6cbd00ca..ef30aba0 100644
--- a/ManicEmu/ManicEmu/Resources/sk.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/sk.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ Ak chcete vylepšiť svoje nastavenie, PlayCase je perfektným doplnkom tohto sk
"ScrollToLastGame" = "Posunúť na poslednú hru";
"ScrollToFirstGame" = "Posunúť na prvú hru";
"WhatsNew" = "Čo je nové vo v%@";
+
+"ICloudROMWiFiOnly" = "Synchronizovať ROM len cez Wi-Fi";
+"ICloudROMSizeLimit" = "Limit veľkosti ROM";
+"ICloudROMSizeLimitUnlimited" = "Bez limitu";
+"ICloudROMSizeLimitDesc" = "ROM väčšie ako táto veľkosť ostanú len na tomto zariadení, aby jediný veľký obraz disku nezaplnil iCloud Drive. Uloženia hier, okamžité uloženia, skiny a nastavenia nie sú nikdy ovplyvnené.";
+"ICloudROMTransferLimitDesc" = "Tieto dva limity platia len pre súbory ROM. Uloženia hier, okamžité uloženia, skiny a nastavenia sa ďalej synchronizujú v akejkoľvek sieti a pri akejkoľvek veľkosti. Otvorenie hry vždy stiahne ROM, aj keď by limit synchronizáciu inak zadržal.";
diff --git a/ManicEmu/ManicEmu/Resources/sv.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/sv.lproj/Localizable.strings
index 2cb9c0f7..f1da34cd 100644
--- a/ManicEmu/ManicEmu/Resources/sv.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/sv.lproj/Localizable.strings
@@ -1152,3 +1152,9 @@ Om du vill höja din upplevelse är PlayCase en perfekt match för detta skin.";
"ScrollToLastGame" = "Scrolla till sista spelet";
"ScrollToFirstGame" = "Scrolla till första spelet";
"WhatsNew" = "Nyheter i v%@";
+
+"ICloudROMWiFiOnly" = "Synka ROM endast via Wi-Fi";
+"ICloudROMSizeLimit" = "Storleksgräns för ROM";
+"ICloudROMSizeLimitUnlimited" = "Ingen gräns";
+"ICloudROMSizeLimitDesc" = "ROM-filer större än så här stannar bara på den här enheten, så att en enda stor skivavbildning inte fyller iCloud Drive. Sparningar, snabbsparningar, skins och inställningar påverkas aldrig.";
+"ICloudROMTransferLimitDesc" = "De här två gränserna gäller bara ROM-filer. Sparningar, snabbsparningar, skins och inställningar fortsätter synkas över alla nätverk och oavsett storlek. När du öppnar ett spel laddas ROM-filen alltid ner, även om en gräns annars skulle hindra synken.";
diff --git a/ManicEmu/ManicEmu/Resources/th.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/th.lproj/Localizable.strings
index 29b3cc4b..816ca34d 100644
--- a/ManicEmu/ManicEmu/Resources/th.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/th.lproj/Localizable.strings
@@ -1148,3 +1148,9 @@ PlayCase มุ่งเน้นที่เคส iPhone คุณภาพส
"ScrollToLastGame" = "เลื่อนไปเกมสุดท้าย";
"ScrollToFirstGame" = "เลื่อนไปเกมแรก";
"WhatsNew" = "มีอะไรใหม่ใน v%@";
+
+"ICloudROMWiFiOnly" = "ซิงค์ ROM เฉพาะ Wi-Fi";
+"ICloudROMSizeLimit" = "จำกัดขนาด ROM";
+"ICloudROMSizeLimitUnlimited" = "ไม่จำกัด";
+"ICloudROMSizeLimitDesc" = "ROM ที่ใหญ่กว่านี้จะเก็บไว้บนอุปกรณ์นี้เท่านั้น เพื่อไม่ให้ไฟล์อิมเมจแผ่นใหญ่ไฟล์เดียวเต็ม iCloud Drive เซฟเกม เซฟทันที สกิน และการตั้งค่าไม่ได้รับผลกระทบ";
+"ICloudROMTransferLimitDesc" = "ข้อจำกัดสองข้อนี้ใช้กับไฟล์ ROM เท่านั้น เซฟเกม เซฟทันที สกิน และการตั้งค่ายังซิงค์ได้ทุกเครือข่ายและทุกขนาด การเปิดเกมจะดาวน์โหลด ROM เสมอ แม้ข้อจำกัดจะกันไม่ให้ซิงค์";
diff --git a/ManicEmu/ManicEmu/Resources/tr.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/tr.lproj/Localizable.strings
index a731d65a..8926d1c3 100644
--- a/ManicEmu/ManicEmu/Resources/tr.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/tr.lproj/Localizable.strings
@@ -1158,3 +1158,9 @@ Kurulumunuzu bir üst seviyeye taşımak istiyorsanız, PlayCase bu kaplama içi
"ScrollToLastGame" = "Son Oyuna Kaydır";
"ScrollToFirstGame" = "İlk Oyuna Kaydır";
"WhatsNew" = "v%@ sürümünde neler yeni";
+
+"ICloudROMWiFiOnly" = "ROM’ları yalnızca Wi-Fi üzerinden senkronize et";
+"ICloudROMSizeLimit" = "ROM boyut sınırı";
+"ICloudROMSizeLimitUnlimited" = "Sınırsız";
+"ICloudROMSizeLimitDesc" = "Bu boyuttan büyük ROM’lar yalnızca bu cihazda tutulur, böylece tek bir büyük disk görüntüsü iCloud Drive’ı doldurmaz. Oyun kayıtları, anlık kayıtlar, skin’ler ve ayarlar etkilenmez.";
+"ICloudROMTransferLimitDesc" = "Bu iki sınır yalnızca ROM dosyalarına uygulanır. Oyun kayıtları, anlık kayıtlar, skin’ler ve ayarlar her ağda ve her boyutta senkron olmaya devam eder. Bir oyunu açmak, sınır senkronu engelleyecek olsa bile ROM’u her zaman indirir.";
diff --git a/ManicEmu/ManicEmu/Resources/uk.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/uk.lproj/Localizable.strings
index faf92d9c..fc71bada 100644
--- a/ManicEmu/ManicEmu/Resources/uk.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/uk.lproj/Localizable.strings
@@ -1159,3 +1159,9 @@ PlayCase спеціалізується на високоякісних чохл
"ScrollToLastGame" = "Прокрутити до останньої гри";
"ScrollToFirstGame" = "Прокрутити до першої гри";
"WhatsNew" = "Що нового у v%@";
+
+"ICloudROMWiFiOnly" = "Синхронізувати ROM лише через Wi-Fi";
+"ICloudROMSizeLimit" = "Обмеження розміру ROM";
+"ICloudROMSizeLimitUnlimited" = "Без обмежень";
+"ICloudROMSizeLimitDesc" = "ROM, більші за цей розмір, залишаються лише на цьому пристрої, щоб один великий образ диска не заповнив iCloud Drive. Збереження, швидкі збереження, скіни та налаштування не зачіпаються.";
+"ICloudROMTransferLimitDesc" = "Ці два обмеження стосуються лише файлів ROM. Збереження, швидкі збереження, скіни та налаштування й далі синхронізуються в будь-якій мережі та за будь-якого розміру. Коли ви відкриваєте гру, ROM завжди завантажується, навіть якщо обмеження інакше не дало б йому синхронізуватися.";
diff --git a/ManicEmu/ManicEmu/Resources/vi.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/vi.lproj/Localizable.strings
index 459668c3..2c388fae 100644
--- a/ManicEmu/ManicEmu/Resources/vi.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/vi.lproj/Localizable.strings
@@ -1152,3 +1152,9 @@ Nếu bạn muốn nâng cấp thiết lập của mình, PlayCase là sự kế
"ScrollToLastGame" = "Cuộn tới trò chơi cuối";
"ScrollToFirstGame" = "Cuộn tới trò chơi đầu";
"WhatsNew" = "Có gì mới trong v%@";
+
+"ICloudROMWiFiOnly" = "Chỉ đồng bộ ROM qua Wi-Fi";
+"ICloudROMSizeLimit" = "Giới hạn dung lượng ROM";
+"ICloudROMSizeLimitUnlimited" = "Không giới hạn";
+"ICloudROMSizeLimitDesc" = "ROM lớn hơn mức này chỉ giữ trên thiết bị này, để một ảnh đĩa lớn không làm đầy iCloud Drive. Bản lưu, lưu trữ tức thời, skin và cài đặt không bị ảnh hưởng.";
+"ICloudROMTransferLimitDesc" = "Hai giới hạn này chỉ áp dụng cho tệp ROM. Bản lưu, lưu trữ tức thời, skin và cài đặt vẫn đồng bộ trên mọi mạng và mọi dung lượng. Mở trò chơi luôn tải ROM, dù giới hạn lẽ ra sẽ chặn đồng bộ.";
diff --git a/ManicEmu/ManicEmu/Resources/zh-HK.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/zh-HK.lproj/Localizable.strings
index 072d49d4..905422ae 100644
--- a/ManicEmu/ManicEmu/Resources/zh-HK.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/zh-HK.lproj/Localizable.strings
@@ -1164,3 +1164,9 @@ PlayCase 專注於製造高品質 iPhone 手機殼,設計時已充分考慮配
"ScrollToLastGame" = "滾動到最後一個遊戲";
"ScrollToFirstGame" = "滾動到第一個遊戲";
"WhatsNew" = "v%@ 有什麼新內容";
+
+"ICloudROMWiFiOnly" = "僅限 Wi-Fi 同步 ROM";
+"ICloudROMSizeLimit" = "ROM 大小限制";
+"ICloudROMSizeLimitUnlimited" = "不限制";
+"ICloudROMSizeLimitDesc" = "超過此大小的 ROM 只會保留在本機,避免單個大型光碟鏡像佔滿 iCloud 雲碟。遊戲存檔、即時存檔、皮膚和設定不受影響。";
+"ICloudROMTransferLimitDesc" = "這兩項限制僅作用於 ROM 檔案。遊戲存檔、即時存檔、皮膚和設定會在任意網絡、任意大小下繼續同步。打開遊戲時始終會下載對應 ROM,即使限制本會阻止同步。";
diff --git a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings
index c0126af1..d5e9b99d 100644
--- a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings
@@ -1187,3 +1187,9 @@
"ScrollToLastGame" = "滚动到最后一个游戏";
"ScrollToFirstGame" = "滚动到第一个游戏";
"WhatsNew" = "v%@ 有什么新内容";
+
+"ICloudROMWiFiOnly" = "仅限 Wi-Fi 同步 ROM";
+"ICloudROMSizeLimit" = "ROM 大小限制";
+"ICloudROMSizeLimitUnlimited" = "不限制";
+"ICloudROMSizeLimitDesc" = "超过此大小的 ROM 只会保留在本机,避免单个大型光盘镜像占满 iCloud 云盘。游戏存档、即时存档、皮肤和设置不受影响。";
+"ICloudROMTransferLimitDesc" = "这两项限制仅作用于 ROM 文件。游戏存档、即时存档、皮肤和设置会在任意网络、任意大小下继续同步。打开游戏时始终会下载对应 ROM,即使限制本会阻止同步。";
diff --git a/ManicEmu/ManicEmu/Resources/zh-Hant.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/zh-Hant.lproj/Localizable.strings
index e0e57583..a7c85282 100644
--- a/ManicEmu/ManicEmu/Resources/zh-Hant.lproj/Localizable.strings
+++ b/ManicEmu/ManicEmu/Resources/zh-Hant.lproj/Localizable.strings
@@ -1164,3 +1164,9 @@ PlayCase 專注於高品質 iPhone 保護殼,設計時充分考慮了配件與
"ScrollToLastGame" = "捲動到最後一個遊戲";
"ScrollToFirstGame" = "捲動到第一個遊戲";
"WhatsNew" = "v%@ 有什麼新內容";
+
+"ICloudROMWiFiOnly" = "僅限 Wi-Fi 同步 ROM";
+"ICloudROMSizeLimit" = "ROM 大小限制";
+"ICloudROMSizeLimitUnlimited" = "不限制";
+"ICloudROMSizeLimitDesc" = "超過此大小的 ROM 只會保留在本機,避免單一大型光碟映像檔佔滿 iCloud 雲碟。遊戲存檔、即時存檔、皮膚和設定不受影響。";
+"ICloudROMTransferLimitDesc" = "這兩項限制僅作用於 ROM 檔案。遊戲存檔、即時存檔、皮膚和設定會在任意網路、任意大小下繼續同步。開啟遊戲時始終會下載對應 ROM,即使限制本會阻止同步。";
diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift
index d1df83c0..3dd02774 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift
@@ -90,6 +90,10 @@ enum ExtraKey: String {
case slowMotionSpeed
case iCloudSyncROM
case iCloudSyncROMPlatforms
+ /// Restrict ROM transfers to Wi-Fi. Saves and other small data ignore this.
+ case iCloudSyncROMWiFiOnly
+ /// Largest ROM, in bytes, allowed to reach iCloud Drive. 0 means no limit.
+ case iCloudSyncROMSizeLimit
case wswanRotation
case wswanPalette
case arcadeType//naomi=1 atomiswave=2 segasp=3
diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swift
index 7f882053..364e55d4 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swift
@@ -18,6 +18,8 @@ class ICloudSettingView: BaseView {
case progress
case platform
case games
+ case romWiFiOnly
+ case romSizeLimit
case repair
}
@@ -86,9 +88,12 @@ class ICloudSettingView: BaseView {
.iconTitleDetailChevronCell(icon: .symbolImage(R.image.category_iconSymbols()),
title: R.string.localizable.iCloudROMPlatformConfig()),
.iconTitleDetailChevronCell(icon: .symbolImage(R.image.games_iconSymbols()),
- title: R.string.localizable.iCloudROMGameConfig())
+ title: R.string.localizable.iCloudROMGameConfig()),
+ romWiFiOnlyCell(),
+ romSizeLimitCell()
], header: .defaultHeader(title: R.string.localizable.iCloudROMSyncSetting()),
- footer: .texts([.smallText(R.string.localizable.iCloudROMSyncDesc(), numberOfLines: 0)], pin: false)))
+ footer: .texts([.smallText(R.string.localizable.iCloudROMSyncDesc(), numberOfLines: 0),
+ .smallText(R.string.localizable.iCloudROMTransferLimitDesc(), numberOfLines: 0)], pin: false)))
sections.append(ASListPage.Section(cells: [
.iconTitleDetailChevronCell(icon: .symbolImage(R.image.refresh_iconSymbols()),
title: R.string.localizable.iCloudRepairSync())
@@ -127,6 +132,56 @@ class ICloudSettingView: BaseView {
enablePressEffect: false)
}
+ private func romWiFiOnlyCell() -> ASListPage.Cell {
+ .iconTitleDetailSwitchCell(icon: .symbolImage(R.image.online_iconSymbols()),
+ title: R.string.localizable.iCloudROMWiFiOnly(),
+ state: FilesSyncPolicy.isROMWiFiOnly ? .on : .off,
+ enablePressEffect: false)
+ }
+
+ private func romSizeLimitCell() -> ASListPage.Cell {
+ .iconTitleDetailChevronCell(icon: .symbolImage(R.image.disc_iconSymbols()),
+ title: R.string.localizable.iCloudROMSizeLimit(),
+ chevronTitle: Self.romSizeLimitTitle(FilesSyncPolicy.romSizeLimit))
+ }
+
+ /// Units read the same in every locale, so only the unlimited case is localized.
+ private static func romSizeLimitTitle(_ bytes: Int64) -> String {
+ guard bytes > 0 else { return R.string.localizable.iCloudROMSizeLimitUnlimited() }
+ let gigabyte: Int64 = 1024 * 1024 * 1024
+ if bytes % gigabyte == 0 {
+ return "\(bytes / gigabyte) GB"
+ }
+ return "\(bytes / (1024 * 1024)) MB"
+ }
+
+ private func showROMSizeLimitConfig() {
+ let options = FilesSyncPolicy.romSizeLimitOptions
+ let current = FilesSyncPolicy.romSizeLimit
+ let cells: [[ASListPage.Cell]] = options.map { limit in
+ [.iconTitleDetailRadioCell(title: Self.romSizeLimitTitle(limit),
+ isSelected: limit == current)]
+ }
+ let sheetStyle: ASSheet.Style = .simpleList(icon: .symbolImage(R.image.disc_iconSymbols()),
+ title: R.string.localizable.iCloudROMSizeLimit(),
+ detail: .smallText(R.string.localizable.iCloudROMSizeLimitDesc(), numberOfLines: 0),
+ options: cells)
+ ASSheetView.show(.init(style: sheetStyle), action: { [weak self] action, _ in
+ guard let index = action.listPageValue?.normalItemValue?.indexPath.section,
+ index < options.count else {
+ return .dismiss()
+ }
+ let limit = options[index]
+ return .dismiss(completion: {
+ guard limit != FilesSyncPolicy.romSizeLimit else { return }
+ FilesSyncPolicy.setROMSizeLimit(limit)
+ self?.reloadList()
+ // A larger ceiling can release ROMs that were previously held back.
+ FilesSyncManager.shared.handleROMTransferLimitsChange()
+ })
+ })
+ }
+
private func refreshContainerSizeIfNeeded() {
guard let iCloudPath = FileManager.default.url(forUbiquityContainerIdentifier: nil)?.path else { return }
containerSizeWorkItem?.cancel()
@@ -159,8 +214,6 @@ class ICloudSettingView: BaseView {
title = R.string.localizable.iCloudSyncing()
}
}
- let total = max(progress.totalCount, 0)
- let completed = min(progress.completedCount, total)
return .iconTitleProgressCell(icon: .symbolImage(R.image.icloudsync_iconSymbols()),
title: title,
progress: .init(value: progress.fraction,
@@ -182,7 +235,13 @@ class ICloudSettingView: BaseView {
if !isSyncEnabled { return nil }
if indexPath.section == 1 { return .progress }
if indexPath.section == 2 {
- return indexPath.row == 0 ? .platform : .games
+ switch indexPath.row {
+ case 0: return .platform
+ case 1: return .games
+ case 2: return .romWiFiOnly
+ case 3: return .romSizeLimit
+ default: return nil
+ }
}
if indexPath.section == 3 { return .repair }
return nil
@@ -228,6 +287,15 @@ class ICloudSettingView: BaseView {
showPlatformConfig()
case .games:
showGameConfig()
+ case .romWiFiOnly:
+ guard let isOn = value.subActions?.extraValue as? Bool else { return }
+ FilesSyncPolicy.setROMWiFiOnly(isOn)
+ listPageView.updateCellData(value.cellData.updateNormalSwitch(state: isOn ? .on : .off),
+ indexPath: value.indexPath)
+ // Leaving Wi-Fi-only can release ROMs that were held back on cellular.
+ FilesSyncManager.shared.handleROMTransferLimitsChange()
+ case .romSizeLimit:
+ showROMSizeLimitConfig()
case .repair:
repairSync()
}
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncEngine.swift b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncEngine.swift
index b7f8d756..6db655d8 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncEngine.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncEngine.swift
@@ -28,6 +28,9 @@ struct FilesSyncOp: Codable {
var retries: Int
/// Unique id so drain completion cannot drop a newer op for the same path.
var token: Int
+ /// Payload size known at enqueue time, used for the ROM size limit. Not persisted:
+ /// a restored op re-reads the size instead.
+ var payloadBytes: Int64
init(relativePath: String,
kind: FilesSyncOpKind,
@@ -35,7 +38,8 @@ struct FilesSyncOp: Codable {
isDirectory: Bool = false,
isConflict: Bool = false,
retries: Int = 0,
- token: Int = 0) {
+ token: Int = 0,
+ payloadBytes: Int64 = 0) {
self.relativePath = relativePath
self.kind = kind
self.tombstoneReason = tombstoneReason
@@ -43,6 +47,7 @@ struct FilesSyncOp: Codable {
self.isConflict = isConflict
self.retries = retries
self.token = token
+ self.payloadBytes = payloadBytes
}
init(from decoder: Decoder) throws {
@@ -54,6 +59,7 @@ struct FilesSyncOp: Codable {
isConflict = try container.decodeIfPresent(Bool.self, forKey: .isConflict) ?? false
retries = try container.decodeIfPresent(Int.self, forKey: .retries) ?? 0
token = try container.decodeIfPresent(Int.self, forKey: .token) ?? 0
+ payloadBytes = 0
}
func encode(to encoder: Encoder) throws {
@@ -94,17 +100,34 @@ final class FilesSyncEngine {
private var latestCloudFiles: [String: FilesSyncFingerprint] = [:]
private var notDownloaded = Set<String>()
private var cloudListingReady = false
+ /// Guarded by `lock`: mutated from the work chain and from `ensureLocal`, which runs
+ /// outside it.
private var romExclusion = FilesSyncROMExclusion()
+ /// Default matches Settings: 1 GB, not unlimited. A 0 here would let a huge ROM
+ /// slip into the queue before the first Realm snapshot.
+ private var romLimits = FilesSyncROMTransferLimits(wifiOnly: false, sizeLimit: FilesSyncPolicy.defaultROMSizeLimit)
+ /// Cellular and hotspot count as metered. Only ROM transfers care.
+ private var networkUnmetered = true
private var pendingLocalNotes: [URL] = []
private var pendingLocalRemovals: [URL] = []
private var pendingInventory: FilesSyncCloudInventory?
private var repairInFlight = false
private var lastProgressPostedAt: TimeInterval = 0
+ private var persistWorkItem: DispatchWorkItem?
+ /// Buffered `present` intents. Written in one Realm transaction so IceCream emits a
+ /// single CloudKit operation instead of one long-lived operation per file.
+ private var pendingIntentMarks: [String: Int64] = [:]
+ private let persistQueue = DispatchQueue(label: "com.aoshuang.manicemu.files-sync-persist", qos: .utility)
+ private let intentFlushThreshold = 64
+ /// How long after a successful transfer the cloud listing may still miss the item.
+ private static let listingLagWindow: TimeInterval = 10 * 60
var onProgress: ((FilesSyncProgress) -> Void)?
- private(set) var progress = FilesSyncProgress() {
- didSet { onProgress?(progress) }
+ private var _progress = FilesSyncProgress()
+
+ var progress: FilesSyncProgress {
+ withLock { _progress }
}
var hasDownloadTask: Bool {
@@ -140,6 +163,9 @@ final class FilesSyncEngine {
func stop() {
Log.debug("[iCloud Sync] stop main=\(Thread.isMainThread) \(queueSummary())")
+ // A debounced write must not land after the snapshot below and blank it out.
+ cancelScheduledPersist()
+ flushIntentMarks()
let snapshot: [String: FilesSyncOp] = withLock {
started = false
drainGeneration += 1
@@ -180,6 +206,7 @@ final class FilesSyncEngine {
pendingLocalNotes.removeAll()
pendingLocalRemovals.removeAll()
pendingInventory = nil
+ pendingIntentMarks.removeAll()
cloudListingReady = false
nextOpToken = 0
repairInFlight = false
@@ -257,7 +284,7 @@ final class FilesSyncEngine {
return
}
self.flushDeferredOps(reason: "repair")
- let stats = await self.reconcile(full: true)
+ let stats = await self.reconcile(full: true, forceCloudListing: true)
Log.debug("[iCloud Sync] repair scan uploads=\(stats.uploads) downloads=\(stats.downloads) deletes=\(stats.deletes)")
DispatchQueue.main.async { handler(.scanFinished(stats)) }
if stats.queued > 0 {
@@ -394,8 +421,13 @@ final class FilesSyncEngine {
#endif
}
+ /// - Parameter forceCloudListing: Re-enumerate the Drive tree even when a cached listing
+ /// exists. Only the user-triggered repair needs this; the enumeration is expensive.
@discardableResult
- func reconcile(full: Bool, cloudFiles: [String: FilesSyncFingerprint]? = nil, saveRootsOnly: Bool = false) async -> FilesSyncRepairStats {
+ func reconcile(full: Bool,
+ cloudFiles: [String: FilesSyncFingerprint]? = nil,
+ saveRootsOnly: Bool = false,
+ forceCloudListing: Bool = false) async -> FilesSyncRepairStats {
#if SIDE_LOAD
return FilesSyncRepairStats()
#else
@@ -414,21 +446,24 @@ final class FilesSyncEngine {
var allCloud: [String: FilesSyncFingerprint]
if let cloudFiles {
allCloud = cloudFiles
- withLock { cloudListingReady = true }
- } else if withLock({ latestCloudFiles.isEmpty }) {
- if let listed = await io.listCloudFiles() {
- allCloud = listed
- withLock { cloudListingReady = true }
- } else {
- allCloud = [:]
+ withLock {
+ latestCloudFiles = cloudFiles
+ cloudListingReady = true
}
- } else {
+ } else if withLock({ cloudListingReady }), !forceCloudListing {
+ // Trust the cached listing. Keying off emptiness instead re-enumerated the whole
+ // Drive tree on every pass whenever the cloud was legitimately empty, and each
+ // directory level costs an NSFileCoordinator round trip.
allCloud = withLock { latestCloudFiles }
- }
- withLock {
- if !allCloud.isEmpty {
- latestCloudFiles = allCloud
+ } else if let listed = await io.listCloudFiles() {
+ allCloud = listed.files
+ withLock {
+ latestCloudFiles = listed.files
+ notDownloaded = listed.notDownloaded
+ cloudListingReady = true
}
+ } else {
+ allCloud = [:]
}
let cloudForDecide: [String: FilesSyncFingerprint]
if saveRootsOnly, !full {
@@ -501,7 +536,7 @@ final class FilesSyncEngine {
let inLedger = ledger[relative] != nil
let inCloud = cloud[relative] != nil
let intent = intents[relative]
- if romExclusion.contains(relative) {
+ if isROMExcluded(relative) {
_ = decide(relativePath: relative, local: localFp, cloud: cloudKnown ? cloud[relative] : nil)
continue
}
@@ -516,7 +551,7 @@ final class FilesSyncEngine {
_ = decide(relativePath: relative, local: localFp, cloud: nil)
}
}
- for (relative, intent) in intents where FilesSyncPolicy.shouldSkipOnSaveScan(relativePath: relative) {
+ for (relative, _) in intents where FilesSyncPolicy.shouldSkipOnSaveScan(relativePath: relative) {
if local[relative] != nil { continue }
if FilesSyncPolicy.shouldNeverSync(relativePath: relative) { continue }
_ = decide(relativePath: relative, local: nil, cloud: cloudKnown ? cloud[relative] : nil)
@@ -555,19 +590,25 @@ final class FilesSyncEngine {
paths.append(relative)
}
Log.debug("[iCloud Sync] local removal \(relative) directory=\(directory) matching=\(paths.count)")
+ // One transaction for the whole subtree: deleting a multi-disc game otherwise emits a
+ // separate CloudKit operation per file.
+ FilesSyncIntentStore.markDeletedBatch(paths)
for path in paths {
- FilesSyncIntentStore.markDeleted(relativePath: path)
let isDir = (path == relative && directory)
|| paths.contains { $0 != path && $0.hasPrefix(path + "/") }
enqueue(FilesSyncOp(relativePath: path, kind: .deleteCloud, tombstoneReason: .deleted, isDirectory: isDir))
}
FilesSyncIndex.save()
- persistQueuedOps()
+ schedulePersistQueuedOps()
pump()
}
private func processExcludeCloudCopies(_ urls: [URL]) async {
guard isStarted else { return }
+ // Collect first, then write all intents in one transaction: excluding a platform can
+ // touch hundreds of files, and one CloudKit operation each would swamp the daemon.
+ var excluded: [String] = []
+ var operations: [FilesSyncOp] = []
for url in urls {
guard let relative = FilesSyncPolicy.documentsRelativePath(from: url) else { continue }
let directory = isDirectory(url) || url.hasDirectoryPath
@@ -576,28 +617,34 @@ final class FilesSyncEngine {
var paths = Array(localFiles.keys)
paths.append(contentsOf: FilesSyncIntentStore.paths(matchingPrefix: relative))
paths.append(relative)
- Log.debug("[iCloud Sync] exclude cloud directory \(relative) files=\(Set(paths).count)")
- for path in Set(paths) {
- FilesSyncIntentStore.markExcluded(relativePath: path)
+ let unique = Set(paths)
+ Log.debug("[iCloud Sync] exclude cloud directory \(relative) files=\(unique.count)")
+ for path in unique {
+ excluded.append(path)
let isDir = (path == relative && directory)
|| paths.contains { $0 != path && $0.hasPrefix(path + "/") }
- enqueue(FilesSyncOp(relativePath: path, kind: .deleteCloud, tombstoneReason: .excluded, isDirectory: isDir))
+ operations.append(FilesSyncOp(relativePath: path, kind: .deleteCloud, tombstoneReason: .excluded, isDirectory: isDir))
}
} else {
Log.debug("[iCloud Sync] exclude cloud file \(relative)")
- FilesSyncIntentStore.markExcluded(relativePath: relative)
- enqueue(FilesSyncOp(relativePath: relative, kind: .deleteCloud, tombstoneReason: .excluded, isDirectory: false))
+ excluded.append(relative)
+ operations.append(FilesSyncOp(relativePath: relative, kind: .deleteCloud, tombstoneReason: .excluded, isDirectory: false))
}
}
+ guard !operations.isEmpty else { return }
+ FilesSyncIntentStore.markExcludedBatch(excluded)
+ for op in operations {
+ enqueue(op)
+ }
FilesSyncIndex.save()
- persistQueuedOps()
+ schedulePersistQueuedOps()
pump()
}
private func performEnsureLocal(_ url: URL) async -> Error? {
guard let relative = FilesSyncPolicy.documentsRelativePath(from: url) else { return nil }
refreshROMExclusion()
- if romExclusion.contains(relative) {
+ if isROMExcluded(relative) {
Log.debug("[iCloud Sync] ensureLocal skipped (ROM excluded): \(relative)")
return NSError(domain: "FilesSync", code: 1, userInfo: [NSLocalizedDescriptionKey: "ROM sync disabled"])
}
@@ -701,7 +748,7 @@ final class FilesSyncEngine {
decided += 1
}
Log.debug("[iCloud Sync] cloud delta decided=\(decided) intentGaps=\(missing) changed=\(changed.count) \(queueSummary())")
- persistQueuedOps()
+ schedulePersistQueuedOps()
pump()
}
@@ -710,21 +757,30 @@ final class FilesSyncEngine {
Log.debug("[iCloud Sync] skip local change (never sync): \(relativePath)")
return
}
- if romExclusion.contains(relativePath) {
+ if isROMExcluded(relativePath) {
Log.debug("[iCloud Sync] skip local change (ROM sync off, leave cloud): \(relativePath)")
return
}
Log.debug("[iCloud Sync] enqueue upload \(relativePath)")
enqueue(FilesSyncOp(relativePath: relativePath, kind: .upload, tombstoneReason: nil))
- persistQueuedOps()
+ schedulePersistQueuedOps()
pump()
}
+ /// A just-uploaded file is absent from the listing for a while: `bird` publishes the item
+ /// asynchronously. Only inside that window do we trust the ledger over the listing, so a
+ /// cloud copy that really was removed elsewhere still gets pushed again later.
+ private func isListingLagging(_ entry: FilesSyncLedgerEntry?) -> Bool {
+ guard let entry else { return false }
+ return Date().timeIntervalSince1970 - entry.lastSyncedAt < Self.listingLagWindow
+ }
+
@discardableResult
private func decide(relativePath: String, local: FilesSyncFingerprint?, cloud: FilesSyncFingerprint?) -> FilesSyncDecideAction {
let intent = FilesSyncIntentStore.snapshot(relativePath: relativePath)
let applied = FilesSyncIndex.appliedGeneration(for: relativePath)
- let ledger = FilesSyncIndex.store.files[relativePath]?.fingerprint
+ let ledgerEntry = FilesSyncIndex.store.files[relativePath]
+ let ledger = ledgerEntry?.fingerprint
// Exclude/delete intents win over "ROM sync off". Turning sync off keeps
// Drive copies; deleting the game or confirming evict must still remove them.
@@ -760,7 +816,7 @@ final class FilesSyncEngine {
// Policy off only stops upload/download. Cloud copies stay until the user
// confirms excludeCloudCopies or deletes the game.
- if romExclusion.contains(relativePath) {
+ if isROMExcluded(relativePath) {
Log.debug("[iCloud Sync] decide \(relativePath) -> skip (ROM sync off)")
return .skip
}
@@ -770,21 +826,25 @@ final class FilesSyncEngine {
case .excluded, .deleted:
return .skip
case .present:
- if applied >= intent.generation, local != nil {
+ if let local, let cloud {
return compareReplicas(relativePath: relativePath, local: local, cloud: cloud, ledger: ledger, intent: intent)
}
- if local == nil {
+ guard let local else {
Log.debug("[iCloud Sync] decide \(relativePath) -> download (intent present gen=\(intent.generation) applied=\(applied) cloud=\(cloud != nil))")
- enqueue(FilesSyncOp(relativePath: relativePath, kind: .download, tombstoneReason: nil))
+ enqueue(FilesSyncOp(relativePath: relativePath, kind: .download, tombstoneReason: nil,
+ payloadBytes: cloud?.size ?? intent.size))
return .download
}
- if cloud == nil {
- // Newer remote generation: wait for the blob instead of re-uploading our older copy.
- Log.debug("[iCloud Sync] decide \(relativePath) -> download (wait for present gen=\(intent.generation) blob) applied=\(applied)")
- enqueue(FilesSyncOp(relativePath: relativePath, kind: .download, tombstoneReason: nil))
- return .download
+ // Local file is here, Drive listing is not. Re-upload after the lag window;
+ // downloading a missing blob would fail and Repair would keep reporting done.
+ if let ledger, local.matches(ledger), isListingLagging(ledgerEntry) {
+ Log.debug("[iCloud Sync] decide \(relativePath) -> skip (synced content, cloud listing lagging)")
+ return .skip
}
- return compareReplicas(relativePath: relativePath, local: local, cloud: cloud, ledger: ledger, intent: intent)
+ Log.debug("[iCloud Sync] decide \(relativePath) -> upload (present, cloud listing missing) applied=\(applied)")
+ enqueue(FilesSyncOp(relativePath: relativePath, kind: .upload, tombstoneReason: nil,
+ payloadBytes: local.size))
+ return .upload
}
}
@@ -793,8 +853,13 @@ final class FilesSyncEngine {
return compareReplicas(relativePath: relativePath, local: local, cloud: cloud, ledger: ledger, intent: nil)
}
if let local, cloud == nil {
+ if let ledger, local.matches(ledger), isListingLagging(ledgerEntry) {
+ // Already pushed this exact content; the cloud listing has not caught up yet.
+ Log.debug("[iCloud Sync] decide \(relativePath) -> skip (synced content, awaiting listing)")
+ return .skip
+ }
Log.debug("[iCloud Sync] decide \(relativePath) -> upload (local only, no intent) \(describe(local))")
- enqueue(FilesSyncOp(relativePath: relativePath, kind: .upload, tombstoneReason: nil))
+ enqueue(FilesSyncOp(relativePath: relativePath, kind: .upload, tombstoneReason: nil, payloadBytes: local.size))
return .upload
}
if local == nil, cloud != nil {
@@ -826,12 +891,12 @@ final class FilesSyncEngine {
return .skip
}
Log.debug("[iCloud Sync] decide \(relativePath) -> download (cloud changed) local=\(describe(local)) cloud=\(describe(cloud))")
- enqueue(FilesSyncOp(relativePath: relativePath, kind: .download, tombstoneReason: nil))
+ enqueue(FilesSyncOp(relativePath: relativePath, kind: .download, tombstoneReason: nil, payloadBytes: cloud.size))
return .download
}
if let ledger, cloud.matches(ledger), !local.matches(ledger) {
Log.debug("[iCloud Sync] decide \(relativePath) -> upload (local changed) local=\(describe(local)) cloud=\(describe(cloud))")
- enqueue(FilesSyncOp(relativePath: relativePath, kind: .upload, tombstoneReason: nil))
+ enqueue(FilesSyncOp(relativePath: relativePath, kind: .upload, tombstoneReason: nil, payloadBytes: local.size))
return .upload
}
if local.matches(cloud) {
@@ -852,7 +917,8 @@ final class FilesSyncEngine {
enqueue(FilesSyncOp(relativePath: relativePath,
kind: localWins ? .upload : .download,
tombstoneReason: nil,
- isConflict: true))
+ isConflict: true,
+ payloadBytes: localWins ? local.size : cloud.size))
return localWins ? .upload : .download
}
@@ -866,11 +932,20 @@ final class FilesSyncEngine {
let local = localExists ? FilesSyncIndex.fingerprint(for: localURL, preferHash: false) : nil
_ = decide(relativePath: relative, local: local, cloud: cloud[relative])
}
- persistQueuedOps()
+ schedulePersistQueuedOps()
pump()
}
- private func enqueue(_ op: FilesSyncOp) {
+ @discardableResult
+ private func enqueue(_ op: FilesSyncOp) -> Bool {
+ if op.kind == .upload || op.kind == .download, let block = romTransferBlockReason(for: op) {
+ // Park both cases: dropping size-blocked ops made "No Limit" and Repair
+ // unable to find them again, and Repair reported them as uploaded.
+ deferForLater(op)
+ Log.debug("[iCloud Sync] hold \(op.kind) \(op.relativePath) (\(block.label))")
+ schedulePersistQueuedOps()
+ return false
+ }
withLock {
nextOpToken += 1
var stamped = op
@@ -878,6 +953,27 @@ final class FilesSyncEngine {
pending[op.relativePath] = stamped
}
Log.debug("[iCloud Sync] queue \(op.kind) \(op.relativePath) \(queueSummary())")
+ return true
+ }
+
+ /// Parks an op without consuming a retry. A queued delete for the same path wins, since
+ /// transferring a file that is about to disappear is pointless.
+ private func deferForLater(_ op: FilesSyncOp) {
+ let parked = withLock { () -> Bool in
+ if let current = pending[op.relativePath],
+ current.kind == .deleteCloud || current.kind == .deleteLocal {
+ return false
+ }
+ nextOpToken += 1
+ var stored = op
+ stored.token = nextOpToken
+ stored.retries = 0
+ pending[op.relativePath] = nil
+ deferred[op.relativePath] = stored
+ return true
+ }
+ guard parked else { return }
+ Log.debug("[iCloud Sync] defer \(op.kind) \(op.relativePath)")
}
private func pump() {
@@ -939,6 +1035,7 @@ final class FilesSyncEngine {
if idle {
Log.debug("[iCloud Sync] drain idle")
if withLock({ drainGeneration == generation }) {
+ flushIntentMarks()
persistQueuedOps()
publish {
$0.phase = .idle
@@ -991,6 +1088,7 @@ final class FilesSyncEngine {
publish { $0.completedCount += finished }
}
if withLock({ drainGeneration == generation }) {
+ flushIntentMarks()
FilesSyncIndex.save()
persistQueuedOps()
}
@@ -1003,6 +1101,12 @@ final class FilesSyncEngine {
Log.debug("[iCloud Sync] run deferred (gameplay) \(op.kind) \(op.relativePath)")
return false
}
+ // The network or the user's limits can change mid-drain, so re-check before transferring.
+ if op.kind == .upload || op.kind == .download, let block = romTransferBlockReason(for: op) {
+ Log.debug("[iCloud Sync] run held \(op.kind) \(op.relativePath) (\(block.label))")
+ deferForLater(op)
+ return true
+ }
let localURL = FilesSyncPolicy.localURL(relativePath: op.relativePath)
switch op.kind {
case .upload:
@@ -1020,8 +1124,10 @@ final class FilesSyncEngine {
}
try await io.upload(localURL: localURL, relativePath: op.relativePath)
if let fingerprint = FilesSyncIndex.fingerprint(for: localURL, preferHash: false) {
- let generation = FilesSyncIntentStore.markPresent(relativePath: op.relativePath, size: fingerprint.size)
- FilesSyncIndex.recordSynced(relativePath: op.relativePath, fingerprint: fingerprint, generation: generation)
+ // Ledger first so a re-scan sees the content as synced, then buffer the
+ // CloudKit intent so a whole batch travels as one operation.
+ FilesSyncIndex.recordSynced(relativePath: op.relativePath, fingerprint: fingerprint)
+ queueIntentMark(relativePath: op.relativePath, size: fingerprint.size)
}
Log.debug("[iCloud Sync] Uploaded \(op.relativePath)")
} catch {
@@ -1114,7 +1220,7 @@ final class FilesSyncEngine {
return false
}
if withLock({ drainGeneration == session && deferred[op.relativePath] != nil }) {
- persistQueuedOps()
+ schedulePersistQueuedOps()
Log.debug("[iCloud Sync] deferred \(op.kind) \(op.relativePath) after \(op.retries) retries")
}
return true
@@ -1148,10 +1254,11 @@ final class FilesSyncEngine {
op.retries = 0
enqueue(op)
}
- persistQueuedOps()
+ schedulePersistQueuedOps()
}
private func persistQueuedOps() {
+ cancelScheduledPersist()
let snapshot: [String: FilesSyncOp] = withLock {
var all = deferred
for (path, op) in pending {
@@ -1162,6 +1269,69 @@ final class FilesSyncEngine {
FilesSyncIndex.savePending(snapshot)
}
+ /// The queue is re-encoded in full on every save, so writing once per enqueue is O(N²)
+ /// across a large import. Coalesce into one write per second instead.
+ private func schedulePersistQueuedOps() {
+ let work: DispatchWorkItem? = withLock {
+ if persistWorkItem != nil { return nil }
+ let item = DispatchWorkItem { [weak self] in
+ guard let self else { return }
+ self.withLock { self.persistWorkItem = nil }
+ self.persistQueuedOps()
+ }
+ persistWorkItem = item
+ return item
+ }
+ guard let work else { return }
+ persistQueue.asyncAfter(deadline: .now() + 1, execute: work)
+ }
+
+ /// Buffers a `present` intent. Flushed as one Realm transaction so IceCream pushes a
+ /// single CloudKit operation for the batch.
+ private func queueIntentMark(relativePath: String, size: Int64) {
+ let shouldFlush = withLock { () -> Bool in
+ pendingIntentMarks[relativePath] = size
+ return pendingIntentMarks.count >= intentFlushThreshold
+ }
+ if shouldFlush {
+ flushIntentMarks()
+ }
+ }
+
+ private func flushIntentMarks() {
+ let batch = withLock { () -> [String: Int64] in
+ let value = pendingIntentMarks
+ pendingIntentMarks = [:]
+ return value
+ }
+ guard !batch.isEmpty else { return }
+ let generations = FilesSyncIntentStore.markPresentBatch(batch)
+ guard !generations.isEmpty else {
+ // The write failed; keep the intents so the next flush retries them.
+ withLock {
+ for (path, size) in batch where pendingIntentMarks[path] == nil {
+ pendingIntentMarks[path] = size
+ }
+ }
+ return
+ }
+ FilesSyncIndex.modify { store in
+ for (path, generation) in generations {
+ store.appliedGenerations[path] = generation
+ }
+ }
+ FilesSyncIndex.save()
+ }
+
+ private func cancelScheduledPersist() {
+ let item = withLock { () -> DispatchWorkItem? in
+ let value = persistWorkItem
+ persistWorkItem = nil
+ return value
+ }
+ item?.cancel()
+ }
+
private func waitUntilIdle() async {
while isStarted {
if withLock({ pausedForGameplay }) {
@@ -1202,11 +1372,83 @@ final class FilesSyncEngine {
return FileManager.default.fileExists(atPath: url.path, isDirectory: &isDir) && isDir.boolValue
}
+ /// Rebuilds the ROM snapshot and limits from Realm. Callers must be off the main thread.
private func refreshROMExclusion() {
- romExclusion = FilesSyncPolicy.romExclusionSnapshot()
- Log.debug("[iCloud Sync] ROM exclusion files=\(romExclusion.files.count) prefixes=\(romExclusion.prefixes.count)")
- if !romExclusion.files.isEmpty {
- Log.debug("[iCloud Sync] ROM excluded files: \(romExclusion.files.sorted().prefix(10).joined(separator: ", "))")
+ let snapshot = FilesSyncPolicy.romExclusionSnapshot()
+ let limits = FilesSyncPolicy.romTransferLimits()
+ withLock {
+ romExclusion = snapshot
+ romLimits = limits
+ }
+ Log.debug("[iCloud Sync] ROM exclusion files=\(snapshot.files.count) prefixes=\(snapshot.prefixes.count) wifiOnly=\(limits.wifiOnly) sizeLimit=\(limits.sizeLimit)")
+ if !snapshot.files.isEmpty {
+ Log.debug("[iCloud Sync] ROM excluded files: \(snapshot.files.sorted().prefix(10).joined(separator: ", "))")
+ }
+ }
+
+ private func isROMExcluded(_ relativePath: String) -> Bool {
+ withLock { romExclusion.contains(relativePath) }
+ }
+
+ // MARK: - ROM Transfer Limits
+
+ private enum ROMTransferBlock {
+ case metered
+ case sizeLimit
+
+ var label: String {
+ switch self {
+ case .metered: return "ROM sync limited to Wi-Fi"
+ case .sizeLimit: return "ROM over size limit"
+ }
+ }
+ }
+
+ /// ROM-only gate. Saves, skins and settings are never held back, and an explicit
+ /// `ensureLocal` bypasses this because it does not go through the queue.
+ private func romTransferBlockReason(for op: FilesSyncOp) -> ROMTransferBlock? {
+ let (exclusion, limits, unmetered) = withLock { (romExclusion, romLimits, networkUnmetered) }
+ guard exclusion.isROM(op.relativePath) else { return nil }
+ if limits.wifiOnly, !unmetered { return .metered }
+ guard limits.sizeLimit > 0 else { return nil }
+ return limits.exceedsSize(payloadBytes(for: op)) ? .sizeLimit : nil
+ }
+
+ private func payloadBytes(for op: FilesSyncOp) -> Int64 {
+ if op.payloadBytes > 0 { return op.payloadBytes }
+ if op.kind == .download, let cloud = withLock({ latestCloudFiles[op.relativePath] }) {
+ return cloud.size
+ }
+ let url = FilesSyncPolicy.localURL(relativePath: op.relativePath)
+ return (try? url.resourceValues(forKeys: [.fileSizeKey]).fileSize).flatMap { Int64($0) } ?? 0
+ }
+
+ /// Metered state from the path monitor. Only ROM transfers react to it.
+ func updateNetworkMetering(unmetered: Bool) {
+ let becameUnmetered = withLock { () -> Bool in
+ let changed = networkUnmetered != unmetered
+ networkUnmetered = unmetered
+ return changed && unmetered
+ }
+ guard becameUnmetered, isStarted else { return }
+ Log.debug("[iCloud Sync] network became unmetered, releasing held ROM transfers")
+ enqueueWork("unmetered") { [weak self] in
+ self?.flushDeferredOps(reason: "unmetered")
+ self?.pump()
+ }
+ }
+
+ /// The user changed the Wi-Fi-only switch or the size ceiling. Held ROM transfers
+ /// must be re-evaluated with the new snapshot; a full local scan catches files that
+ /// were dropped by older builds which did not park size-blocked ops.
+ func handleROMLimitsChange() {
+ guard isStarted else { return }
+ Log.debug("[iCloud Sync] ROM transfer limits changed")
+ enqueueWork("romLimits") { [weak self] in
+ guard let self else { return }
+ self.refreshROMExclusion()
+ self.flushDeferredOps(reason: "romLimits")
+ await self.reconcile(full: true)
}
}
@@ -1242,23 +1484,31 @@ final class FilesSyncEngine {
return "size=\(fingerprint.size) mtime=\(Int(fingerprint.mtime))"
}
+ /// Single writer for `_progress`. Drain and the metadata work chain run concurrently,
+ /// so the read-modify-write must happen under the lock.
private func publish(_ update: (inout FilesSyncProgress) -> Void) {
- var next = progress
- update(&next)
- let phaseChanged = next.phase != progress.phase
- if phaseChanged || next.currentFileName != progress.currentFileName || next.totalCount != progress.totalCount {
- Log.debug("[iCloud Sync] progress phase=\(next.phase.rawValue) file=\(next.currentFileName ?? "-") completed=\(next.completedCount)/\(next.totalCount)")
- }
- progress = next
- let shouldPost = withLock { () -> Bool in
+ let result = withLock { () -> (next: FilesSyncProgress, describe: Bool, post: Bool) in
+ var next = _progress
+ update(&next)
+ let phaseChanged = next.phase != _progress.phase
+ let describe = phaseChanged
+ || next.currentFileName != _progress.currentFileName
+ || next.totalCount != _progress.totalCount
+ _progress = next
let now = Date().timeIntervalSince1970
+ var post = false
if phaseChanged || next.phase == .idle || now - lastProgressPostedAt >= 0.25 {
lastProgressPostedAt = now
- return true
+ post = true
}
- return false
+ return (next, describe, post)
+ }
+ if result.describe {
+ Log.debug("[iCloud Sync] progress phase=\(result.next.phase.rawValue) file=\(result.next.currentFileName ?? "-") completed=\(result.next.completedCount)/\(result.next.totalCount)")
}
- guard shouldPost else { return }
+ guard result.post else { return }
+ let next = result.next
+ onProgress?(next)
DispatchQueue.main.async {
NotificationCenter.default.post(name: R.NotificationName.iCloudDriveSyncChange, object: next)
}
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncIO.swift b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncIO.swift
index d5d0909d..05e82d31 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncIO.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncIO.swift
@@ -9,16 +9,27 @@
import Foundation
import SwiftCloudDrive
+/// One pass over the Drive tree. `notDownloaded` matters because placeholders report a
+/// misleading on-disk size, which would otherwise look like a conflict.
+struct FilesSyncCloudListing {
+ var files: [String: FilesSyncFingerprint] = [:]
+ var notDownloaded: Set<String> = []
+}
+
final class FilesSyncIO {
+ /// A drain transfers a batch concurrently, so every access goes through `stateLock`.
+ private let stateLock = NSLock()
private var cloudDrive: CloudDrive?
+ private var lastAccountCheckAt: TimeInterval = 0
+
+ /// The drive must never pull files on its own: the engine decides what to fetch, and a
+ /// ROM library would otherwise be materialized in full regardless of the user's settings.
+ private static let driveOptions = CloudDrive.Options(downloadsAllFilesAutomatically: false)
+ /// The token lookup reaches the iCloud daemon, so it is not worth doing per transfer.
+ private static let accountCheckInterval: TimeInterval = 5
func prepare() async throws {
- if cloudDrive == nil {
- Log.debug("[iCloud Sync] CloudDrive init begin main=\(Thread.isMainThread)")
- let startedAt = Date()
- cloudDrive = try await CloudDrive()
- Log.debug("[iCloud Sync] CloudDrive init end elapsed=\(String(format: "%.2f", Date().timeIntervalSince(startedAt)))s")
- }
+ _ = try await resolvedDrive()
}
func fileExists(relativePath: String) async -> Bool {
@@ -33,10 +44,14 @@ final class FilesSyncIO {
enum FilesSyncIOError: Swift.Error {
case missingLocal
+ case notSignedIn
}
func resetSession() {
- cloudDrive = nil
+ withStateLock {
+ cloudDrive = nil
+ lastAccountCheckAt = 0
+ }
}
func upload(localURL: URL, relativePath: String) async throws {
@@ -78,6 +93,8 @@ final class FilesSyncIO {
Log.debug("[iCloud Sync] Download begin \(relativePath) main=\(Thread.isMainThread)")
let drive = try await resolvedDrive()
let cloudPath = RootRelativePath(path: FilesSyncPolicy.cloudRootPath(relativePath: relativePath))
+ // Nothing materializes files for us any more, so pull this one before copying it out.
+ try await drive.ensureDownloaded(at: cloudPath)
let tempURL = URL(fileURLWithPath: R.Path.Temp.appendingPathComponent(UUID().uuidString + "-" + localURL.lastPathComponent))
try await drive.download(from: cloudPath, toURL: tempURL)
try FileManager.default.createDirectory(at: localURL.deletingLastPathComponent(), withIntermediateDirectories: true)
@@ -119,29 +136,57 @@ final class FilesSyncIO {
}
}
- func listCloudFiles() async -> [String: FilesSyncFingerprint]? {
+ func listCloudFiles() async -> FilesSyncCloudListing? {
let startedAt = Date()
guard let drive = try? await resolvedDrive() else {
Log.debug("[iCloud Sync] listCloudFiles skipped: CloudDrive unavailable")
return nil
}
- var result: [String: FilesSyncFingerprint] = [:]
- await collectCloudFiles(at: RootRelativePath(path: "Documents"), drive: drive, into: &result)
- Log.debug("[iCloud Sync] listCloudFiles count=\(result.count) elapsed=\(String(format: "%.2f", Date().timeIntervalSince(startedAt)))s main=\(Thread.isMainThread)")
- return result
+ var listing = FilesSyncCloudListing()
+ await collectCloudFiles(at: RootRelativePath(path: "Documents"), drive: drive, into: &listing)
+ Log.debug("[iCloud Sync] listCloudFiles count=\(listing.files.count) notDownloaded=\(listing.notDownloaded.count) elapsed=\(String(format: "%.2f", Date().timeIntervalSince(startedAt)))s main=\(Thread.isMainThread)")
+ return listing
}
private func resolvedDrive() async throws -> CloudDrive {
- if let cloudDrive { return cloudDrive }
- let drive = try await CloudDrive()
- cloudDrive = drive
- return drive
+ // A sign-out leaves the cached drive pointing at a container we can no longer use, so
+ // re-validate the account periodically instead of trusting the cache forever.
+ let (cached, needsAccountCheck) = withStateLock { () -> (CloudDrive?, Bool) in
+ let now = Date().timeIntervalSince1970
+ guard cloudDrive != nil, now - lastAccountCheckAt < Self.accountCheckInterval else {
+ lastAccountCheckAt = now
+ return (cloudDrive, true)
+ }
+ return (cloudDrive, false)
+ }
+ if needsAccountCheck, FileManager.default.ubiquityIdentityToken == nil {
+ resetSession()
+ throw FilesSyncIOError.notSignedIn
+ }
+ if let cached { return cached }
+ Log.debug("[iCloud Sync] CloudDrive init begin main=\(Thread.isMainThread)")
+ let startedAt = Date()
+ let drive = try await CloudDrive(options: Self.driveOptions)
+ Log.debug("[iCloud Sync] CloudDrive init end elapsed=\(String(format: "%.2f", Date().timeIntervalSince(startedAt)))s")
+ // Another task may have won the race; keep its instance so only one file monitor lives.
+ return withStateLock { () -> CloudDrive in
+ if let existing = cloudDrive { return existing }
+ cloudDrive = drive
+ return drive
+ }
+ }
+
+ private func withStateLock<T>(_ body: () -> T) -> T {
+ stateLock.lock()
+ defer { stateLock.unlock() }
+ return body()
}
private func collectCloudFiles(at path: RootRelativePath,
drive: CloudDrive,
- into result: inout [String: FilesSyncFingerprint]) async {
- let keys: [URLResourceKey] = [.isRegularFileKey, .isDirectoryKey, .contentModificationDateKey, .fileSizeKey]
+ into listing: inout FilesSyncCloudListing) async {
+ let keys: [URLResourceKey] = [.isRegularFileKey, .isDirectoryKey, .contentModificationDateKey,
+ .fileSizeKey, .totalFileSizeKey, .ubiquitousItemDownloadingStatusKey]
guard let items = try? await drive.contentsOfDirectory(at: path, includingPropertiesForKeys: keys, options: [.skipsHiddenFiles]) else {
return
}
@@ -152,11 +197,18 @@ final class FilesSyncIO {
continue
}
if values.isDirectory == true {
- await collectCloudFiles(at: RootRelativePath(path: FilesSyncPolicy.cloudRootPath(relativePath: relative)), drive: drive, into: &result)
+ await collectCloudFiles(at: RootRelativePath(path: FilesSyncPolicy.cloudRootPath(relativePath: relative)), drive: drive, into: &listing)
} else if values.isRegularFile == true {
- let size = Int64(values.fileSize ?? 0)
+ // A placeholder's fileSize is its on-disk stub, not the real payload. Using it
+ // would look like a size conflict and trigger a pointless transfer.
+ let isPlaceholder = values.ubiquitousItemDownloadingStatus == .notDownloaded
+ if isPlaceholder {
+ listing.notDownloaded.insert(relative)
+ }
+ let logical = values.totalFileSize ?? values.fileSize ?? 0
+ let size = Int64(isPlaceholder ? logical : (values.fileSize ?? logical))
let mtime = values.contentModificationDate?.timeIntervalSince1970 ?? 0
- result[relative] = FilesSyncFingerprint(size: size, mtime: mtime, hash: nil)
+ listing.files[relative] = FilesSyncFingerprint(size: size, mtime: mtime, hash: nil)
}
}
}
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncManager.swift b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncManager.swift
index db7cee4f..62515800 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncManager.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncManager.swift
@@ -90,8 +90,10 @@ final class FilesSyncManager {
}
private init() {
+ // `progress` feeds `syncState`, which the UI reads on the main thread, so keep the
+ // assignment there instead of writing it from the engine's worker threads.
engine.onProgress = { [weak self] progress in
- self?.progress = progress
+ DispatchQueue.main.async { self?.progress = progress }
}
watchers.onCloudInventory = { [weak self] inventory in
self?.engine.applyCloudInventory(inventory)
@@ -289,6 +291,16 @@ final class FilesSyncManager {
#endif
}
+ /// The user changed the Wi-Fi-only switch or the ROM size ceiling.
+ func handleROMTransferLimitsChange() {
+#if SIDE_LOAD
+ return
+#else
+ guard FilesSyncPolicy.isDriveSyncAvailable else { return }
+ engine.handleROMLimitsChange()
+#endif
+ }
+
/// Upload or evict Drive copies after the user assigns or changes GameType.
func applyROMSyncAfterGameTypeChange(for games: [Game]) {
#if SIDE_LOAD
@@ -371,8 +383,11 @@ final class FilesSyncManager {
let satisfied = path.status == .satisfied
let becameSatisfied = satisfied && !self.networkSatisfied
self.networkSatisfied = satisfied
+ // Hotspots report as Wi-Fi but bill like cellular, so trust the system's own
+ // expensive/constrained flags rather than the interface type.
+ self.engine.updateNetworkMetering(unmetered: satisfied && !path.isExpensive && !path.isConstrained)
if becameSatisfied {
- Log.debug("[iCloud Sync] network became satisfied")
+ Log.debug("[iCloud Sync] network became satisfied expensive=\(path.isExpensive) constrained=\(path.isConstrained)")
self.engine.handleNetworkSatisfied()
} else if !satisfied {
Log.debug("[iCloud Sync] network unsatisfied")
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncPolicy.swift b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncPolicy.swift
index e169a81d..aee0766e 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncPolicy.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncPolicy.swift
@@ -7,13 +7,30 @@
//
import Foundation
+import CoreFoundation
import RealmSwift
struct FilesSyncROMExclusion {
var files: Set<String> = []
var prefixes: Set<String> = []
+ /// Every game's ROM paths, regardless of their sync flag. Lets ROM-only transfer
+ /// limits apply without touching saves, skins and other small data.
+ var romFiles: Set<String> = []
+ var romPrefixes: Set<String> = []
+ /// ROM sync is off for this path, so uploads and downloads are skipped.
func contains(_ relativePath: String) -> Bool {
+ Self.matches(relativePath, files: files, prefixes: prefixes)
+ }
+
+ /// The path belongs to a game's ROM payload rather than to small app data.
+ func isROM(_ relativePath: String) -> Bool {
+ if FilesSyncPolicy.isROMContentTree(relativePath: relativePath) { return true }
+ if FilesSyncPolicy.isInstalled3DSContent(relativePath: relativePath) { return true }
+ return Self.matches(relativePath, files: romFiles, prefixes: romPrefixes)
+ }
+
+ private static func matches(_ relativePath: String, files: Set<String>, prefixes: Set<String>) -> Bool {
if files.contains(relativePath) { return true }
for prefix in prefixes {
if relativePath == prefix || relativePath.hasPrefix(prefix + "/") {
@@ -24,6 +41,17 @@ struct FilesSyncROMExclusion {
}
}
+/// ROM-only transfer limits, snapshotted so the engine avoids per-path Realm reads.
+struct FilesSyncROMTransferLimits {
+ var wifiOnly: Bool = false
+ var sizeLimit: Int64 = 0
+
+ /// ROM exceeds the configured ceiling, so it must not reach iCloud Drive.
+ func exceedsSize(_ bytes: Int64) -> Bool {
+ sizeLimit > 0 && bytes > sizeLimit
+ }
+}
+
enum FilesSyncPolicy {
private static let neverSyncPrefixes = [
"wpkdata",
@@ -205,14 +233,94 @@ enum FilesSyncPolicy {
#else
let games = Database.realm.objects(Game.self).where { !$0.isDeleted }
for game in games {
+ collectROMPaths(game: game, files: &snapshot.romFiles, prefixes: &snapshot.romPrefixes)
guard !shouldSyncROM(game) else { continue }
collectROMPaths(game: game, files: &snapshot.files, prefixes: &snapshot.prefixes)
}
- Log.debug("[iCloud Sync] ROM exclusion snapshot games=\(games.count) files=\(snapshot.files.count) prefixes=\(snapshot.prefixes.count)")
+ Log.debug("[iCloud Sync] ROM exclusion snapshot games=\(games.count) files=\(snapshot.files.count) prefixes=\(snapshot.prefixes.count) romFiles=\(snapshot.romFiles.count) romPrefixes=\(snapshot.romPrefixes.count)")
return snapshot
#endif
}
+ // MARK: - ROM Transfer Limits
+
+ /// Selectable ceilings for a single ROM reaching iCloud Drive. 0 means no limit.
+ static let romSizeLimitOptions: [Int64] = [
+ 100 * 1024 * 1024,
+ 200 * 1024 * 1024,
+ 500 * 1024 * 1024,
+ 1024 * 1024 * 1024,
+ 0
+ ]
+
+ static let defaultROMSizeLimit: Int64 = 1024 * 1024 * 1024
+
+ /// Transfer ROM payloads only on unmetered networks. Off by default so ROM sync
+ /// works out of the box; saves and other small data ignore this entirely.
+ static var isROMWiFiOnly: Bool {
+#if SIDE_LOAD
+ return false
+#else
+ guard let raw = threadLocalSettings()?.getExtra(key: ExtraKey.iCloudSyncROMWiFiOnly.rawValue) else {
+ return false
+ }
+ if let flag = raw as? Bool { return flag }
+ if let number = raw as? NSNumber { return number.boolValue }
+ return false
+#endif
+ }
+
+ static func setROMWiFiOnly(_ enabled: Bool) {
+#if SIDE_LOAD
+ return
+#else
+ threadLocalSettings()?.updateExtra(key: ExtraKey.iCloudSyncROMWiFiOnly.rawValue, value: enabled)
+#endif
+ }
+
+ /// Largest ROM allowed to reach iCloud Drive, in bytes. 0 means no limit.
+ static var romSizeLimit: Int64 {
+#if SIDE_LOAD
+ return 0
+#else
+ guard let raw = threadLocalSettings()?.getExtra(key: ExtraKey.iCloudSyncROMSizeLimit.rawValue) else {
+ return defaultROMSizeLimit
+ }
+ return extraInt64(raw) ?? defaultROMSizeLimit
+#endif
+ }
+
+ static func setROMSizeLimit(_ bytes: Int64) {
+#if SIDE_LOAD
+ return
+#else
+ // Persist as NSNumber so JSON 0 (No Limit) does not disappear or become a Bool.
+ threadLocalSettings()?.updateExtra(key: ExtraKey.iCloudSyncROMSizeLimit.rawValue, value: NSNumber(value: bytes))
+#endif
+ }
+
+ /// JSON extras type-erase numbers. NSNumber 0 also bridges to `false`, which must
+ /// still mean "No Limit" rather than falling back to the 1 GB default.
+ private static func extraInt64(_ raw: Any) -> Int64? {
+ if let number = raw as? NSNumber {
+ if CFGetTypeID(number) == CFBooleanGetTypeID() {
+ return number.boolValue ? 1 : 0
+ }
+ return number.int64Value
+ }
+ if let value = raw as? Int64 { return value }
+ if let value = raw as? Int { return Int64(value) }
+ if let value = raw as? Double { return Int64(value) }
+ if let value = raw as? String { return Int64(value) }
+ if let value = raw as? Bool { return value ? 1 : 0 }
+ return nil
+ }
+
+ /// Snapshot of both ROM limits, so the engine reads Realm once per scan.
+ static func romTransferLimits() -> FilesSyncROMTransferLimits {
+ FilesSyncROMTransferLimits(wifiOnly: isROMWiFiOnly, sizeLimit: romSizeLimit)
+ }
+
static func collectROMPaths(game: Game, files: inout Set<String>, prefixes: inout Set<String>) {
for url in game.iCloudROMFileURLs {
guard let relative = documentsRelativePath(from: url) else { continue }
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncRecord.swift b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncRecord.swift
index 4cd7aecc..a92ea9dc 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncRecord.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncRecord.swift
@@ -132,6 +132,68 @@ enum FilesSyncIntentStore {
write(relativePath: relativePath, intent: .excluded, size: 0, bump: true)
}
+ /// Batch variants exist because IceCream turns every Realm notification into its own
+ /// long-lived `CKModifyRecordsOperation`. Writing one path at a time leaves `cloudd`
+ /// juggling thousands of operations during an import, which drags down the whole system.
+ @discardableResult
+ static func markPresentBatch(_ sizes: [String: Int64]) -> [String: Int] {
+ writeBatch(sizes.map { (path: $0.key, size: $0.value) }, intent: .present)
+ }
+
+ @discardableResult
+ static func markDeletedBatch(_ paths: [String]) -> [String: Int] {
+ writeBatch(paths.map { (path: $0, size: Int64(0)) }, intent: .deleted)
+ }
+
+ @discardableResult
+ static func markExcludedBatch(_ paths: [String]) -> [String: Int] {
+ writeBatch(paths.map { (path: $0, size: Int64(0)) }, intent: .excluded)
+ }
+
+ private static func writeBatch(_ items: [(path: String, size: Int64)],
+ intent: FilesSyncIntentKind) -> [String: Int] {
+ guard !items.isEmpty else { return [:] }
+ let realm = Database.realm
+ let now = Date()
+ let device = Device.version().rawValue
+ var generations: [String: Int] = [:]
+ generations.reserveCapacity(items.count)
+ do {
+ try realm.write {
+ for item in items {
+ let id = FilesSyncRecord.objectId(forPath: item.path)
+ if let existing = realm.object(ofType: FilesSyncRecord.self, forPrimaryKey: id), !existing.isDeleted {
+ let generation = existing.generation + 1
+ existing.generation = generation
+ existing.intent = intent
+ existing.size = item.size
+ existing.updatedAt = now
+ existing.device = device
+ existing.path = item.path
+ generations[item.path] = generation
+ } else {
+ let record = FilesSyncRecord()
+ record.id = id
+ record.path = item.path
+ record.generation = 1
+ record.size = item.size
+ record.intent = intent
+ record.updatedAt = now
+ record.device = device
+ record.isDeleted = false
+ realm.add(record, update: .modified)
+ generations[item.path] = 1
+ }
+ }
+ }
+ } catch {
+ Log.debug("[iCloud Sync] intent batch \(intentLabel(intent)) failed count=\(items.count): \(error)")
+ return [:]
+ }
+ Log.debug("[iCloud Sync] intent batch \(intentLabel(intent)) count=\(items.count)")
+ return generations
+ }
+
static func pruneExpiredDeleted() {
let cutoff = Date().addingTimeInterval(-pruneAfter)
let realm = Database.realm
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncWatchers.swift b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncWatchers.swift
index fdeb3b9c..7cc75bb7 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncWatchers.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Sync/FilesSyncWatchers.swift
@@ -18,6 +18,19 @@ struct FilesSyncCloudInventory {
}
final class FilesSyncWatchers: NSObject {
+ /// One cached row per cloud file, so an emit is pure in-memory aggregation. Reading
+ /// ubiquitous attributes is an IPC round trip to the iCloud daemon, and doing it for
+ /// every file on every update was the bulk of this class's CPU cost.
+ private struct CloudEntry {
+ var size: Int64
+ var mtime: TimeInterval
+ var notDownloaded: Bool
+ var uploading: Bool
+ var downloading: Bool
+ /// Share of `size` already transferred, 0...100.
+ var percent: Double
+ }
+
private let metadataQuery = NSMetadataQuery()
/// Query notifications and result walks stay off the main thread. Reading
/// ubiquitous item attributes can block on the iCloud daemon.
@@ -29,20 +42,39 @@ final class FilesSyncWatchers: NSObject {
return queue
}()
private var tokens: [NSObjectProtocol] = []
+ private let lock = NSLock()
private var isRunning = false
private var emitWorkItem: DispatchWorkItem?
+ /// Only touched on `queryQueue`, which is serial.
+ private var entries: [String: CloudEntry] = [:]
+ private var needsFullRebuild = true
var onCloudInventory: ((FilesSyncCloudInventory) -> Void)?
+ private var running: Bool {
+ lock.lock()
+ defer { lock.unlock() }
+ return isRunning
+ }
+
func start() {
- guard !isRunning else { return }
+ lock.lock()
+ if isRunning {
+ lock.unlock()
+ return
+ }
guard FileManager.default.ubiquityIdentityToken != nil else {
+ lock.unlock()
Log.debug("[iCloud Sync] No iCloud account, skip metadata query")
return
}
isRunning = true
+ lock.unlock()
Log.debug("[iCloud Sync] metadata query start main=\(Thread.isMainThread)")
+ queryQueue.addOperation { [weak self] in
+ self?.needsFullRebuild = true
+ }
DispatchQueue.main.async { [weak self] in
- guard let self, self.isRunning else { return }
+ guard let self, self.running else { return }
self.configureIfNeeded()
self.metadataQuery.enableUpdates()
self.metadataQuery.start()
@@ -50,9 +82,12 @@ final class FilesSyncWatchers: NSObject {
}
func stop() {
+ lock.lock()
isRunning = false
- emitWorkItem?.cancel()
+ let work = emitWorkItem
emitWorkItem = nil
+ lock.unlock()
+ work?.cancel()
Log.debug("[iCloud Sync] metadata query stop")
DispatchQueue.main.async { [weak self] in
self?.metadataQuery.stop()
@@ -68,23 +103,62 @@ final class FilesSyncWatchers: NSObject {
guard tokens.isEmpty else { return }
metadataQuery.searchScopes = [NSMetadataQueryUbiquitousDocumentsScope]
metadataQuery.predicate = NSPredicate(value: true)
- metadataQuery.notificationBatchingInterval = 1
+ metadataQuery.notificationBatchingInterval = 2
metadataQuery.operationQueue = queryQueue
let center = NotificationCenter.default
let finish = center.addObserver(forName: .NSMetadataQueryDidFinishGathering, object: metadataQuery, queue: queryQueue) { [weak self] _ in
- self?.scheduleEmit(immediate: true)
+ guard let self, self.running else { return }
+ self.needsFullRebuild = true
+ self.scheduleEmit(immediate: true)
}
- let update = center.addObserver(forName: .NSMetadataQueryDidUpdate, object: metadataQuery, queue: queryQueue) { [weak self] _ in
- self?.scheduleEmit(immediate: false)
+ let update = center.addObserver(forName: .NSMetadataQueryDidUpdate, object: metadataQuery, queue: queryQueue) { [weak self] notification in
+ self?.applyUpdate(notification)
}
tokens = [finish, update]
}
+ /// Applies the query's added/changed/removed deltas to the cache. Runs on the serial
+ /// `queryQueue`, so attribute reads only happen for items that actually moved.
+ private func applyUpdate(_ notification: Notification) {
+ guard running else { return }
+ guard let userInfo = notification.userInfo else {
+ needsFullRebuild = true
+ scheduleEmit(immediate: false)
+ return
+ }
+ var touched = 0
+ for key in [NSMetadataQueryUpdateAddedItemsKey, NSMetadataQueryUpdateChangedItemsKey] {
+ guard let changed = userInfo[key] as? [Any] else { continue }
+ for case let item as NSMetadataItem in changed where absorb(item) {
+ touched += 1
+ }
+ }
+ if let removed = userInfo[NSMetadataQueryUpdateRemovedItemsKey] as? [Any] {
+ for case let item as NSMetadataItem in removed {
+ if let relative = Self.relativePath(for: item) {
+ if entries.removeValue(forKey: relative) != nil {
+ touched += 1
+ }
+ } else if Self.fileURL(for: item) == nil {
+ // A removed item that can no longer report its URL would leave a stale row
+ // claiming the file is still in the cloud. Resync from the result set.
+ needsFullRebuild = true
+ }
+ }
+ }
+ guard touched > 0 || needsFullRebuild else { return }
+ scheduleEmit(immediate: false)
+ }
+
private func scheduleEmit(immediate: Bool) {
- emitWorkItem?.cancel()
+ lock.lock()
+ let previous = emitWorkItem
+ emitWorkItem = nil
+ lock.unlock()
+ previous?.cancel()
+
if immediate {
- emitWorkItem = nil
emitInventory()
return
}
@@ -93,68 +167,108 @@ final class FilesSyncWatchers: NSObject {
self?.emitInventory()
}
}
+ lock.lock()
emitWorkItem = work
+ lock.unlock()
DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + 0.75, execute: work)
}
- private func emitInventory() {
- guard isRunning else { return }
+ /// Reads one item's attributes into the cache. Returns false when the item is not a
+ /// syncable file.
+ private func absorb(_ item: NSMetadataItem) -> Bool {
+ guard let relative = Self.relativePath(for: item) else { return false }
+ if let contentType = item.value(forAttribute: NSMetadataItemContentTypeKey) as? String,
+ contentType == "public.directory" || contentType == "public.folder" {
+ entries[relative] = nil
+ return false
+ }
+
+ let size = (item.value(forAttribute: NSMetadataItemFSSizeKey) as? NSNumber)?.int64Value ?? 0
+ let mtime = (item.value(forAttribute: NSMetadataItemFSContentChangeDateKey) as? Date)?.timeIntervalSince1970 ?? 0
+ let status = item.value(forAttribute: NSMetadataUbiquitousItemDownloadingStatusKey) as? String
+ let notDownloaded = status == NSMetadataUbiquitousItemDownloadingStatusNotDownloaded
+ let uploadPercent = (item.value(forAttribute: NSMetadataUbiquitousItemPercentUploadedKey) as? NSNumber)?.doubleValue
+ let downloadPercent = (item.value(forAttribute: NSMetadataUbiquitousItemPercentDownloadedKey) as? NSNumber)?.doubleValue
+
+ var uploading = (item.value(forAttribute: NSMetadataUbiquitousItemIsUploadingKey) as? Bool) == true
+ if !uploading, let percent = uploadPercent, percent > 0, percent < 100 {
+ uploading = true
+ }
+ var downloading = (item.value(forAttribute: NSMetadataUbiquitousItemIsDownloadingKey) as? Bool) == true
+ if !downloading, let percent = downloadPercent, percent > 0, percent < 100 {
+ downloading = true
+ }
+
+ let percent: Double
+ if uploading, let uploadPercent {
+ percent = uploadPercent
+ } else if downloading, let downloadPercent {
+ percent = downloadPercent
+ } else if notDownloaded {
+ percent = 0
+ } else {
+ percent = 100
+ }
+
+ entries[relative] = CloudEntry(size: size,
+ mtime: mtime,
+ notDownloaded: notDownloaded,
+ uploading: uploading,
+ downloading: downloading,
+ percent: min(max(percent, 0), 100))
+ return true
+ }
+
+ private static func fileURL(for item: NSMetadataItem) -> URL? {
+ item.value(forAttribute: NSMetadataItemURLKey) as? URL
+ }
+
+ /// Nil for items outside Documents, for never-synced paths, and for items that cannot
+ /// report a URL. Callers that need to tell those apart also check `fileURL(for:)`.
+ private static func relativePath(for item: NSMetadataItem) -> String? {
+ guard let fileURL = fileURL(for: item),
+ let relative = FilesSyncPolicy.documentsRelativePath(from: fileURL) else { return nil }
+ if FilesSyncPolicy.shouldNeverSync(relativePath: relative) { return nil }
+ if fileURL.path.hasSuffix("/") { return nil }
+ return relative
+ }
+
+ /// Walks the whole result set. Only needed after the initial gather, or if a delta
+ /// notification arrived without payload.
+ private func rebuildAll() {
let startedAt = Date()
metadataQuery.disableUpdates()
let items = metadataQuery.results
- var inventory = FilesSyncCloudInventory()
- inventory.files.reserveCapacity(items.count)
+ entries.removeAll(keepingCapacity: true)
+ entries.reserveCapacity(items.count)
for case let item as NSMetadataItem in items {
- guard let fileURL = item.value(forAttribute: NSMetadataItemURLKey) as? URL,
- let relative = FilesSyncPolicy.documentsRelativePath(from: fileURL) else { continue }
- if FilesSyncPolicy.shouldNeverSync(relativePath: relative) { continue }
- if fileURL.path.hasSuffix("/") { continue }
- if let contentType = item.value(forAttribute: NSMetadataItemContentTypeKey) as? String,
- contentType == "public.directory" || contentType == "public.folder" {
- continue
- }
-
- let size = (item.value(forAttribute: NSMetadataItemFSSizeKey) as? NSNumber)?.int64Value ?? 0
- let mtime = (item.value(forAttribute: NSMetadataItemFSContentChangeDateKey) as? Date)?.timeIntervalSince1970 ?? 0
- inventory.files[relative] = FilesSyncFingerprint(size: size, mtime: mtime, hash: nil)
-
- let status = item.value(forAttribute: NSMetadataUbiquitousItemDownloadingStatusKey) as? String
- if status == NSMetadataUbiquitousItemDownloadingStatusNotDownloaded {
- inventory.notDownloaded.insert(relative)
- }
-
- let uploadPercent = (item.value(forAttribute: NSMetadataUbiquitousItemPercentUploadedKey) as? NSNumber)?.doubleValue
- let downloadPercent = (item.value(forAttribute: NSMetadataUbiquitousItemPercentDownloadedKey) as? NSNumber)?.doubleValue
- if (item.value(forAttribute: NSMetadataUbiquitousItemIsUploadingKey) as? Bool) == true {
- inventory.uploading.insert(relative)
- } else if let percent = uploadPercent, percent > 0, percent < 100 {
- inventory.uploading.insert(relative)
- }
- if (item.value(forAttribute: NSMetadataUbiquitousItemIsDownloadingKey) as? Bool) == true {
- inventory.downloading.insert(relative)
- } else if let percent = downloadPercent, percent > 0, percent < 100 {
- inventory.downloading.insert(relative)
- }
-
- if size > 0 {
- inventory.bytesTotal += size
- let percent: Double
- if inventory.uploading.contains(relative), let uploadPercent {
- percent = uploadPercent
- } else if inventory.downloading.contains(relative), let downloadPercent {
- percent = downloadPercent
- } else if status == NSMetadataUbiquitousItemDownloadingStatusNotDownloaded {
- percent = 0
- } else {
- percent = 100
- }
- inventory.bytesTransferred += Int64(Double(size) * min(max(percent, 0), 100) / 100)
- }
+ _ = absorb(item)
}
- if isRunning {
+ if running {
metadataQuery.enableUpdates()
}
- Log.debug("[iCloud Sync] metadata emit files=\(inventory.files.count) uploading=\(inventory.uploading.count) downloading=\(inventory.downloading.count) notDownloaded=\(inventory.notDownloaded.count) elapsed=\(String(format: "%.2f", Date().timeIntervalSince(startedAt)))s main=\(Thread.isMainThread)")
+ needsFullRebuild = false
+ Log.debug("[iCloud Sync] metadata full rebuild items=\(items.count) tracked=\(entries.count) elapsed=\(String(format: "%.2f", Date().timeIntervalSince(startedAt)))s")
+ }
+
+ private func emitInventory() {
+ guard running else { return }
+ if needsFullRebuild {
+ rebuildAll()
+ }
+ var inventory = FilesSyncCloudInventory()
+ inventory.files.reserveCapacity(entries.count)
+ for (relative, entry) in entries {
+ inventory.files[relative] = FilesSyncFingerprint(size: entry.size, mtime: entry.mtime, hash: nil)
+ if entry.notDownloaded { inventory.notDownloaded.insert(relative) }
+ if entry.uploading { inventory.uploading.insert(relative) }
+ if entry.downloading { inventory.downloading.insert(relative) }
+ if entry.size > 0 {
+ inventory.bytesTotal += entry.size
+ inventory.bytesTransferred += Int64(Double(entry.size) * entry.percent / 100)
+ }
+ }
+ Log.debug("[iCloud Sync] metadata emit files=\(inventory.files.count) uploading=\(inventory.uploading.count) downloading=\(inventory.downloading.count) notDownloaded=\(inventory.notDownloaded.count) main=\(Thread.isMainThread)")
onCloudInventory?(inventory)
}
}