Skip to content

Commit cc1bf76

Browse files
committed
more logging when livesync
1 parent e49284a commit cc1bf76

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/src/com/tns/NativeScriptSyncService.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.content.pm.PackageManager.NameNotFoundException;
2424
import android.net.LocalServerSocket;
2525
import android.net.LocalSocket;
26+
import android.util.Log;
2627

2728
public 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

Comments
 (0)