Problem description
Using Anvil for SyncServer testing, an issue is surfacing when using Ti.Filesystem.getFile for checking folder.
Attached sample code run manually on device works as expected.
See lines 153 to 170 of the attached sample code 'app.js':
function copyfiles(){
var srcDataDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "myfiles");
var destDataDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "myfiles");
destDataDir.createDirectory();
var files = srcDataDir.getDirectoryListing();
var qty = files.length;
Ti.API.info('#### qty: ' + JSON.stringify(qty));
for(var i = 0; i < (qty-1); i++) {
var srcFile = Ti.Filesystem.getFile(srcDataDir.nativePath, files[i]);
var destFile = Ti.Filesystem.getFile(destDataDir.nativePath, files[i]);
destFile.write(srcFile.read());
if (!destFile.exists()) {
alert(destFile.nativePath);
};
}
}
When run on device, it works as expected (destFile.exists() returns true).
However, running the same code on Anvil and adding a valueOf check:
valueOf(testRun,destFile.exists()).shouldBeTrue();
is returning false, thus an error.
'externalfilesync.js' file attached is the Anvil test sample - see 'function copyfiles()' line 214.
Anvil is no longer supported, this ticket is now irrelevant.