Skip to content
Snippets Groups Projects
Commit 2543a7db authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Prevent database dump while it is scanning

parent ddb9c251
No related branches found
No related tags found
No related merge requests found
......@@ -121,34 +121,37 @@ public class PreferencesAdvanced extends BasePreferenceFragment implements Share
android.os.Process.killProcess(android.os.Process.myPid());
return true;
case "dump_media_db":
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final Runnable dump = new Runnable() {
@Override
public void run() {
final File db = new File(VLCApplication.getAppContext().getDir("db", Context.MODE_PRIVATE)+ Medialibrary.VLC_MEDIA_DB_NAME);
Medialibrary.getInstance().pauseBackgroundOperations();
if (FileUtils.copyFile(db, new File(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY+ Medialibrary.VLC_MEDIA_DB_NAME)))
VLCApplication.runOnMainThread(new Runnable() {
if (VLCApplication.getMLInstance().isWorking())
UiTools.snacker(getView(), getString(R.string.settings_ml_block_scan));
else {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final Runnable dump = new Runnable() {
@Override
public void run() {
final File db = new File(VLCApplication.getAppContext().getDir("db", Context.MODE_PRIVATE)+ Medialibrary.VLC_MEDIA_DB_NAME);
if (FileUtils.copyFile(db, new File(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + Medialibrary.VLC_MEDIA_DB_NAME)))
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
Toast.makeText(VLCApplication.getAppContext(), "Database dumped on internal storage root", Toast.LENGTH_LONG).show();
}
});
else VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
Toast.makeText(VLCApplication.getAppContext(), "Database dumped on internal storage root", Toast.LENGTH_LONG).show();
Toast.makeText(VLCApplication.getAppContext(), "Failed to dumped database", Toast.LENGTH_LONG).show();
}
});
else VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
Toast.makeText(VLCApplication.getAppContext(), "Failed to dumped database", Toast.LENGTH_LONG).show();
}
});
Medialibrary.getInstance().resumeBackgroundOperations();
}
};
if (Permissions.canWriteStorage()) dump.run();
else Permissions.askWriteStoragePermission(getActivity(), false, dump);
}
});
}
};
if (Permissions.canWriteStorage()) dump.run();
else Permissions.askWriteStoragePermission(getActivity(), false, dump);
}
});
}
return true;
}
return super.onPreferenceTreeClick(preference);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment