X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/27112bd200e1bf30897ae94507afeeb272e267ec..8e36e7cc3e6218ccb80ee2af3eb0a19df24e339f:/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java diff --git a/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java b/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java index 6d339e00..0e9838e6 100644 --- a/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java +++ b/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java @@ -1,9 +1,10 @@ /* ownCloud Android client application * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2012-2013 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or + * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -22,12 +23,12 @@ import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; import java.util.Random; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PutMethod; +import com.owncloud.android.Log_OC; import com.owncloud.android.datamodel.OCFile; import android.accounts.Account; @@ -39,16 +40,17 @@ import eu.alefzero.webdav.WebdavUtils; public class ChunkedUploadFileOperation extends UploadFileOperation { - private static final long CHUNK_SIZE = 102400; + private static final long CHUNK_SIZE = 1024000; private static final String OC_CHUNKED_HEADER = "OC-Chunked"; private static final String TAG = ChunkedUploadFileOperation.class.getSimpleName(); public ChunkedUploadFileOperation( Account account, OCFile file, boolean isInstant, - boolean forceOverwrite) { + boolean forceOverwrite, + int localBehaviour) { - super(account, file, isInstant, forceOverwrite); + super(account, file, isInstant, forceOverwrite, localBehaviour); } @Override @@ -56,13 +58,11 @@ public class ChunkedUploadFileOperation extends UploadFileOperation { int status = -1; FileChannel channel = null; - FileLock lock = null; RandomAccessFile raf = null; try { File file = new File(getStoragePath()); - raf = new RandomAccessFile(file, "rw"); + raf = new RandomAccessFile(file, "r"); channel = raf.getChannel(); - lock = channel.tryLock(); ChunkFromFileChannelRequestEntity entity = new ChunkFromFileChannelRequestEntity(channel, getMimeType(), CHUNK_SIZE, file); entity.addOnDatatransferProgressListeners(getDataTransferListeners()); long offset = 0; @@ -75,14 +75,12 @@ public class ChunkedUploadFileOperation extends UploadFileOperation { mPutMethod.setRequestEntity(entity); status = client.executeMethod(mPutMethod); client.exhaustResponse(mPutMethod.getResponseBodyAsStream()); - Log.d(TAG, "Upload of " + getStoragePath() + " to " + getRemotePath() + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status); + Log_OC.d(TAG, "Upload of " + getStoragePath() + " to " + getRemotePath() + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status); if (!isSuccess(status)) break; } } finally { - if (lock != null) - lock.release(); if (channel != null) channel.close(); if (raf != null)