Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit d9322ded authored by davigonz's avatar davigonz Committed by AndyScherzinger
Browse files

Set modification date from the file in filesystem to the file to upload

# Conflicts:
#	src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java
parent 637c59eb
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -60,11 +60,17 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
    private Context mContext;

    public ChunkedUploadRemoteFileOperation(
            Context context, String storagePath, String remotePath, String mimeType, String requiredEtag) {
        super(storagePath, remotePath, mimeType, requiredEtag);
            Context context, String storagePath, String remotePath, String mimeType, String requiredEtag, String fileLastModifTimestamp) {
        super(storagePath, remotePath, mimeType, requiredEtag, fileLastModifTimestamp);
        mContext = context;
    }

    public ChunkedUploadRemoteFileOperation(
            String storagePath, String remotePath, String mimeType, String requiredEtag, String fileLastModifTimestamp
    ){
		 super(storagePath, remotePath, mimeType, requiredEtag, fileLastModifTimestamp);
	}
    
    @Override
    protected int uploadFile(OwnCloudClient client) throws IOException {
        int status = -1;
@@ -114,10 +120,7 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
                mPutMethod.addRequestHeader(OC_CHUNK_SIZE_HEADER, chunkSizeStr);
                mPutMethod.addRequestHeader(OC_TOTAL_LENGTH_HEADER, totalLengthStr);

                // Tell to the server what is the last modification date of the file to upload
                Long timeStampLong = System.currentTimeMillis()/1000;
                String timeStamp = timeStampLong.toString();
                mPutMethod.addRequestHeader(OC_CHUNK_X_OC_MTIME_HEADER, timeStamp);
                mPutMethod.addRequestHeader(OC_CHUNK_X_OC_MTIME_HEADER, mFileLastModifTimestamp);

                ((ChunkFromFileChannelRequestEntity) mEntity).setOffset(offset);
                mPutMethod.setRequestEntity(mEntity);
+117 −118
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public class UploadRemoteFileOperation extends RemoteOperation {
    protected String mLocalPath;
    protected String mRemotePath;
    protected String mMimeType;
    protected String mFileLastModifTimestamp;
    protected PutMethod mPutMethod = null;
    protected boolean mForbiddenCharsInServer = false;
    protected String mRequiredEtag = null;
@@ -76,14 +77,15 @@ public class UploadRemoteFileOperation extends RemoteOperation {

    protected RequestEntity mEntity = null;

	public UploadRemoteFileOperation(String localPath, String remotePath, String mimeType) {
    public UploadRemoteFileOperation(String localPath, String remotePath, String mimeType, String fileLastModifTimestamp) {
        mLocalPath = localPath;
        mRemotePath = remotePath;
        mMimeType = mimeType;
        mFileLastModifTimestamp = fileLastModifTimestamp;
    }

	public UploadRemoteFileOperation(String localPath, String remotePath, String mimeType, String requiredEtag) {
		this(localPath, remotePath, mimeType);
    public UploadRemoteFileOperation(String localPath, String remotePath, String mimeType, String requiredEtag, String fileLastModifTimestamp) {
        this(localPath, remotePath, mimeType, fileLastModifTimestamp);
        mRequiredEtag = requiredEtag;
    }

@@ -154,10 +156,7 @@ public class UploadRemoteFileOperation extends RemoteOperation {
            }
            mPutMethod.addRequestHeader(OC_TOTAL_LENGTH_HEADER, String.valueOf(f.length()));

            // Tell to the server what is the last modification date of the file to upload
            Long timeStampLong = System.currentTimeMillis()/1000;
            String timeStamp = timeStampLong.toString();
            mPutMethod.addRequestHeader(OC_X_OC_MTIME_HEADER, timeStamp);
            mPutMethod.addRequestHeader(OC_X_OC_MTIME_HEADER, mFileLastModifTimestamp);

            mPutMethod.setRequestEntity(mEntity);
            status = client.executeMethod(mPutMethod);