Commit 5530a3a5 authored by fallenstardust's avatar fallenstardust

fix文件已存在时覆盖空文件

parent c59b4627
...@@ -215,24 +215,28 @@ public class GameUriManager { ...@@ -215,24 +215,28 @@ public class GameUriManager {
try { try {
File yrp = new File(AppsSettings.get().getResourcePath() + "/" + CORE_REPLAY_PATH + "/" + urifile.getName().toLowerCase(Locale.US)); File yrp = new File(AppsSettings.get().getResourcePath() + "/" + CORE_REPLAY_PATH + "/" + urifile.getName().toLowerCase(Locale.US));
ParcelFileDescriptor pfd = getActivity().getContentResolver().openFileDescriptor(uri, "r"); ParcelFileDescriptor pfd = getActivity().getContentResolver().openFileDescriptor(uri, "r");
if (pfd == null) { if (yrp.exists()) {
return; YGOStarter.startGame(getActivity(), null);
} else { } else {
try { if (pfd == null) {
FileUtils.copyFile(new FileInputStream(pfd.getFileDescriptor()), yrp); return;
} catch (Throwable e) { } else {
Toast.makeText(activity, activity.getString(R.string.install_failed_bcos) + e, Toast.LENGTH_LONG).show(); try {
} finally { FileUtils.copyFile(new FileInputStream(pfd.getFileDescriptor()), yrp);
pfd.close(); } catch (Throwable e) {
Toast.makeText(activity, activity.getString(R.string.install_failed_bcos) + e, Toast.LENGTH_LONG).show();
} finally {
pfd.close();
}
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
} if (!ComponentUtils.isActivityRunning(activity, new ComponentName(activity, YGOMobileActivity.class))) {
if (!ComponentUtils.isActivityRunning(activity, new ComponentName(activity, YGOMobileActivity.class))) { YGOStarter.startGame(activity, null);
YGOStarter.startGame(activity, null); Toast.makeText(activity, activity.getString(R.string.yrp_installed), Toast.LENGTH_LONG).show();
Toast.makeText(activity, activity.getString(R.string.yrp_installed), Toast.LENGTH_LONG).show(); }
} }
} else { } else {
String host = uri.getHost(); String host = uri.getHost();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment