@@ -131,19 +131,19 @@ public LiveSyncWorker(LocalSocket systemSocket) throws IOException {
131131 }
132132
133133 public void run () {
134- boolean exceptionWhileLivesyncing = false ;
135134 try {
136135
137136 output .write (context .getPackageName ().getBytes ());
138137
139138 } catch (IOException e ) {
140139 logger .write (String .format ("Error while LiveSyncing: Client socket might be closed!" , e .toString ()));
141- exceptionWhileLivesyncing = true ;
142140 e .printStackTrace ();
143141 }
144142 try {
145143 do {
146144 int operation = getOperation ();
145+
146+ System .out .println ("Operation: " + input .available ());
147147 if (operation == DELETE_FILE_OPERATION ) {
148148
149149 String fileName = getFileName ();
@@ -155,20 +155,20 @@ public void run() {
155155 byte [] content = getFileContent (fileName );
156156 createOrOverrideFile (fileName , content );
157157
158-
159158 } else if (operation == DEFAULT_OPERATION ) {
160159 logger .write ("LiveSync: input stream is empty!" );
161160 break ;
162161 } else {
163162 throw new IllegalArgumentException (String .format ("\n LiveSync: Operation not recognised. %s" , LIVESYNC_ERROR_SUGGESTION ));
164163 }
165164
166- } while (this .input .available () > 0 );
165+ //TODO: do debouncing
166+ runtime .runScript (new File (NativeScriptSyncService .this .context .getFilesDir (), "internal/livesync.js" ));
167+ } while (true );
167168
168169 } catch (Exception e ) {
169170 logger .write (String .format ("Error while LiveSyncing: %s" , e .toString ()));
170171 e .printStackTrace ();
171- exceptionWhileLivesyncing = true ;
172172 flushInputStream ();
173173 } catch (Throwable e ) {
174174 logger .write (String .format ("%s(%s): Error while LiveSyncing.\n Original Exception: %s" , Thread .currentThread ().getName (), Thread .currentThread ().getId (), e .toString ()));
@@ -179,14 +179,11 @@ public void run() {
179179 }
180180 }
181181
182- if (!exceptionWhileLivesyncing ) {
183- runtime .runScript (new File (NativeScriptSyncService .this .context .getFilesDir (), "internal/livesync.js" ));
184- }
185182 }
186183
187184 private void flushInputStream () {
188185 try {
189- this .input .skip (1000000 );
186+ this .input .skip (Long . MAX_VALUE );
190187 } catch (IOException e ) {
191188 }
192189 }
@@ -205,8 +202,6 @@ private int getOperation() {
205202 }
206203 operation = Integer .parseInt (new String (operationBuff ));
207204
208- } catch (NumberFormatException e ) {
209- throw new IllegalStateException (String .format ("\n LiveSync: failed to parse %s. %s\n Original Exception: %s" , OPERATION , LIVESYNC_ERROR_SUGGESTION , e .toString ()));
210205 } catch (Exception e ) {
211206 throw new IllegalStateException (String .format ("\n LiveSync: failed to parse %s. %s\n Original Exception: %s" , OPERATION , LIVESYNC_ERROR_SUGGESTION , e .toString ()));
212207 }
0 commit comments