aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-07-22 15:16:58 -0700
committerScott Jackson <daneren2005@gmail.com>2014-07-22 15:16:58 -0700
commitfe3bb692f1b82fa1f5e37e7e095ce04876848717 (patch)
treed4d19c23a8b9adab950ecd38d3c9bcc140127d30 /src
parent35ed56188ab450f14703e39db7c70f5beb18d00a (diff)
downloaddsub-fe3bb692f1b82fa1f5e37e7e095ce04876848717.tar.gz
dsub-fe3bb692f1b82fa1f5e37e7e095ce04876848717.tar.bz2
dsub-fe3bb692f1b82fa1f5e37e7e095ce04876848717.zip
#357 Start of Madsonic specific startRescan functionality
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index 74b78b97..15f06a3e 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -197,6 +197,35 @@ public class RESTMusicService implements MusicService {
Util.close(reader);
}
}
+
+ @Override
+ public void startRescan(Context context, ProgressListener listener) throws Exception {
+ Reader reader = getReader(context, listener, "startRescan", null);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+
+ // Now check if still running
+ boolean done = false;
+ while(!done) {
+ reader = getReader(context, listener, "scanstatus", null);
+ try {
+ ScanStatus status = new ScanStatusParser(context).parse(reader);
+ if(status.isRunning()) {
+ // Don't run system ragged trying to query too much
+ Thread.sleep(100L);
+ } else {
+ done = true;
+ }
+ } catch(Exception e) {
+ done = true;
+ } finally {
+ Util.close(reader);
+ }
+ }
+ }
@Override
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) throws Exception {