Commit 5fb418e0 authored by Geoffrey Métais's avatar Geoffrey Métais

New function for recursive deletion of directories

CID #1226286
parent 62d3e5f7
......@@ -456,7 +456,7 @@ public class MediaDatabase {
PLAYLIST_MEDIA_ORDER + "=?",
new String[] { playlistName, Integer.toString(position) });
playlistShiftItems(playlistName, position+1, -1);
playlistShiftItems(playlistName, position + 1, -1);
}
/**
......@@ -849,6 +849,20 @@ public class MediaDatabase {
mDb.delete(DIR_TABLE_NAME, DIR_ROW_PATH + "=?", new String[] { path });
}
/**
* Delete all matching directories from directories table
*
* @param path
*/
public synchronized void recursiveRemoveDir(String path) {
for(File f : getMediaDirs()) {
final String dirPath = f.getPath();
if(dirPath.startsWith(path))
mDb.delete(DIR_TABLE_NAME, DIR_ROW_PATH + "=?", new String[] { dirPath });
}
}
/**
*
* @return
......
......@@ -128,14 +128,7 @@ public class BrowserActivity extends ListActivity {
@Override
public boolean onMenuItemClick(MenuItem arg0) {
// remove any checkmarks of the custom item
final MediaDatabase dbManager = MediaDatabase.getInstance();
synchronized (dbManager) {
for(File f : dbManager.getMediaDirs()) {
final String path = f.getPath();
if(path.startsWith(item.getPath()))
dbManager.removeDir(path);
}
}
MediaDatabase.getInstance().recursiveRemoveDir(item.getPath());
CustomDirectories.removeCustomDirectory(item.getPath());
refresh();
return true;
......
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