mirror of
https://github.com/izzy2lost/PSX2.git
synced 2026-07-05 15:18:36 -07:00
fix corrupt png on covers download
This commit is contained in:
@@ -213,16 +213,19 @@ public class GamesCoverDialogFragment extends DialogFragment {
|
||||
serial = buildSerialFromUri(uris[i]);
|
||||
}
|
||||
coverUrls[i] = buildCoverUrlFromSerial(serial);
|
||||
// Prefer SAF content URI if data root is set, else absolute file path
|
||||
// Prefer SAF content URI if data root is set and the file already exists.
|
||||
// Do NOT pre-create empty placeholder files here (they cause confusing zero-byte files
|
||||
// alongside downloaded covers). If the SAF file doesn't exist yet, fall back to a
|
||||
// filesystem path and let the downloader create the SAF file when performing the
|
||||
// actual download (startDownloadCovers will create the SAF child as needed).
|
||||
android.net.Uri dataRoot = SafManager.getDataRootUri(requireContext());
|
||||
if (dataRoot != null) {
|
||||
androidx.documentfile.provider.DocumentFile f = SafManager.getChild(requireContext(), new String[]{"covers"}, serial + ".png");
|
||||
if (f != null && f.exists()) {
|
||||
localPaths[i] = f.getUri().toString();
|
||||
} else {
|
||||
// Pre-create to get a stable Uri
|
||||
androidx.documentfile.provider.DocumentFile nf = SafManager.createChild(requireContext(), new String[]{"covers"}, serial + ".png", "image/png");
|
||||
localPaths[i] = (nf != null) ? nf.getUri().toString() : new java.io.File(getCoversDir(), serial + ".png").getAbsolutePath();
|
||||
// Don't create an empty file here; use the file-system fallback path instead.
|
||||
localPaths[i] = new java.io.File(getCoversDir(), serial + ".png").getAbsolutePath();
|
||||
}
|
||||
} else {
|
||||
localPaths[i] = new java.io.File(getCoversDir(), serial + ".png").getAbsolutePath();
|
||||
@@ -551,16 +554,6 @@ public class GamesCoverDialogFragment extends DialogFragment {
|
||||
} catch (Throwable ignored) {}
|
||||
});
|
||||
}
|
||||
|
||||
View btnAchievements = header.findViewById(R.id.drawer_btn_achievements);
|
||||
if (btnAchievements != null) {
|
||||
btnAchievements.setOnClickListener(v -> {
|
||||
try {
|
||||
AchievementsDialogFragment achievementsDialog = AchievementsDialogFragment.newInstance();
|
||||
achievementsDialog.show(getParentFragmentManager(), "achievements");
|
||||
} catch (Throwable ignored) {}
|
||||
});
|
||||
}
|
||||
|
||||
// Setup drawer settings controls to mirror quick actions
|
||||
setupDialogDrawerSettings(header);
|
||||
|
||||
Reference in New Issue
Block a user