Log.v(TAG,"This is a new folder, we must register it");
//persist new syncedFolder
intsyncedFolder_id=(int)DbHelper.insertSyncedFolder(syncedFolder,this);//It will return -1 if there is an error, like an already existing folder with same value
if(syncedFolder_id>0){
Log.v(TAG,"Folder has been registered in DB");
syncedFolder.setId(syncedFolder_id);
}else{
Log.w(TAG,"syncedFolder "+syncedFolder.getLocalFolder()+" remove iterator because it hasn't been registered in DB or already stored");
finalintsyncedFolder_id=(int)DbHelper.insertSyncedFolder(syncedFolder,this);//It will return -1 if there is an error, like an already existing folder with same value
if(syncedFolder_id<=0){
iterator.remove();
continue;
}
syncedFolder.setId(syncedFolder_id);
}
//Get local folder corresponding
FilelocalFolder=newFile(syncedFolder.getLocalFolder());//Obtention du fichier local
if(subElt.isDirectory()){//if its a subfolder add it to syncedFolder list
//if a subfolder is found, add it to syncedFolder list
Log.v(TAG,"subfile "+subElt.getAbsolutePath()+" is a directory.");
SyncedFoldersubSyncedFolder=newSyncedFolder(syncedFolder,subElt.getName()+FileUtils.PATH_SEPARATOR,0L,"");//Need to put 0 into to be handled on next iterati
finalFile[]subFiles=localDirectory.listFiles(filter);//skip hidden media files
if(subFiles==null)continue;
for(FilesubFile:subFiles){
if(subFile.isDirectory()){
finalSyncedFoldersubSyncedFolder=newSyncedFolder(syncedFolder,subFile.getName()+FileUtils.PATH_SEPARATOR,0L,"");//Need to set lastModified to 0 to handle it on next iteration
iterator.add(subSyncedFolder);
iterator.previous();
}else{
if(folderHasChange){//only consider files if folder had change
Log.v(TAG,"subfile "+subElt.getAbsolutePath()+" is a file added to list of file to sync");
fileList.add(subElt);
}elseif(contentToSyncFound){
Log.v(TAG,"added subfile "+subFile.getAbsolutePath()+" into list of file to sync");
fileList.add(subFile);
}
}
}
}//end of iterator loop
if(contentToSyncFound){
DbHelper.updateSyncedFolders(mSyncedFolders,this);//@ToDo: maybe do this when all contents will be synced.