X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/3113c459092dbb3dea60e50efe61070e38804b09..f40fe2c98595fac0c417fdc3638e36b416470984:/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java diff --git a/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java b/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java index 73b74ed5..ef7a3d5b 100644 --- a/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java +++ b/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java @@ -20,6 +20,7 @@ package eu.alefzero.owncloud.syncadapter; import java.io.IOException; import java.io.ObjectInputStream.GetField; +import java.util.List; import java.util.Vector; import org.apache.jackrabbit.webdav.DavException; @@ -50,6 +51,14 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { private final static String TAG = "FileSyncAdapter"; + /* Commented code for ugly performance tests + private final static int MAX_DELAYS = 100; + private static long[] mResponseDelays = new long[MAX_DELAYS]; + private static long[] mSaveDelays = new long[MAX_DELAYS]; + private int mDelaysIndex = 0; + private int mDelaysCount = 0; + */ + private long mCurrentSyncTime; public FileSyncAdapter(Context context, boolean autoInitialize) { @@ -66,6 +75,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { this.setStorageManager(new FileDataStorageManager(account, getContentProvider())); + /* Commented code for ugly performance tests + mDelaysIndex = 0; + mDelaysCount = 0; + */ + + Log.d(TAG, "syncing owncloud account " + account.name); sendStickyBroadcast(true, null); // message to signal the start to the UI @@ -101,21 +116,50 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { Log.e(TAG, "problem while synchronizing owncloud account " + account.name, t); t.printStackTrace(); } + + /* Commented code for ugly performance tests + long sum = 0, mean = 0, max = 0, min = Long.MAX_VALUE; + for (int i=0; i updatedFiles = new Vector(resp.getResponses().length - 1); for (int i = 1; i < resp.getResponses().length; ++i) { WebdavEntry we = new WebdavEntry(resp.getResponses()[i], getUri().getPath()); OCFile file = fillOCFile(we); @@ -128,15 +172,27 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { intent.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount()); intent.putExtra(FileDownloader.EXTRA_FILE_PATH, file.getURLDecodedRemotePath()); intent.putExtra(FileDownloader.EXTRA_REMOTE_PATH, file.getRemotePath()); + intent.putExtra(FileDownloader.EXTRA_FILE_SIZE, file.getFileLength()); file.setKeepInSync(true); getContext().startService(intent); } - getStorageManager().saveFile(file); + if (getStorageManager().getFileByPath(file.getRemotePath()) != null) + file.setKeepInSync(getStorageManager().getFileByPath(file.getRemotePath()).keepInSync()); + //getStorageManager().saveFile(file); + updatedFiles.add(file); if (parentId == 0) parentId = file.getFileId(); } + /* Commented code for ugly performance tests + long saveDelay = System.currentTimeMillis(); + */ + getStorageManager().saveFiles(updatedFiles); // all "at once" ; trying to get a best performance in database update + /* Commented code for ugly performance tests + saveDelay = System.currentTimeMillis() - saveDelay; + Log.e(TAG, "syncing: SAVE TIME for " + uri + " contents, " + mSaveDelays[mDelaysIndex] + "ms"); + */ - // removal of old files + // removal of obsolete files Vector files = getStorageManager().getDirectoryContent( getStorageManager().getFileById(parentId)); OCFile file; @@ -159,6 +215,16 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { fetchData(getUri().toString() + newFile.getRemotePath(), syncResult, newFile.getFileId(), account); } } + + /* Commented code for ugly performance tests + mResponseDelays[mDelaysIndex] = responseDelay; + mSaveDelays[mDelaysIndex] = saveDelay; + mDelaysCount++; + mDelaysIndex++; + if (mDelaysIndex >= MAX_DELAYS) + mDelaysIndex = 0; + */ + } catch (OperationCanceledException e) {