2323import android .content .pm .PackageManager .NameNotFoundException ;
2424import android .net .LocalServerSocket ;
2525import android .net .LocalSocket ;
26+ import android .util .Log ;
2627
2728public class NativeScriptSyncService
2829{
@@ -247,6 +248,12 @@ private void moveFiles(File sourceDir, String sourceRootAbsolutePath, String tar
247248
248249 if (files != null )
249250 {
251+ if (logger .isEnabled ())
252+ {
253+ logger .write ("Syncing total number of fiiles: " + files .length );
254+ }
255+
256+
250257 for (int i = 0 ; i < files .length ; i ++)
251258 {
252259 File file = files [i ];
@@ -278,6 +285,13 @@ private void moveFiles(File sourceDir, String sourceRootAbsolutePath, String tar
278285 }
279286 }
280287 }
288+ else
289+ {
290+ if (logger .isEnabled ())
291+ {
292+ logger .write ("Can't move files. Source is empty." );
293+ }
294+ }
281295 }
282296
283297 // this removes only the app directory from the device to preserve
@@ -299,10 +313,18 @@ private void executePartialSync(Context context, File sourceDir)
299313 String appPath = context .getFilesDir ().getAbsolutePath () + "/app" ;
300314 final File appDir = new File (appPath );
301315
302- if (appDir .exists ())
316+ if (! appDir .exists ())
303317 {
304- moveFiles (sourceDir , sourceDir .getAbsolutePath (), appDir .getAbsolutePath ());
318+ Log .e ("TNS" , "Application dir does not exists. Partial Sync failed. appDir: " + appPath );
319+ return ;
320+ }
321+
322+ if (logger .isEnabled ())
323+ {
324+ logger .write ("Syncing sourceDir " + sourceDir .getAbsolutePath () + " with " + appDir .getAbsolutePath ());
305325 }
326+
327+ moveFiles (sourceDir , sourceDir .getAbsolutePath (), appDir .getAbsolutePath ());
306328 }
307329
308330 private void deleteRemovedFiles (File sourceDir , String sourceRootAbsolutePath , String targetRootAbsolutePath )
0 commit comments