work in progress

This commit is contained in:
madwasp79 2019-02-11 12:50:40 +02:00
parent bc1dc403b2
commit d2613d3620
2 changed files with 8 additions and 12 deletions

View file

@ -1976,7 +1976,10 @@ public class OsmandAidlApi {
} }
private boolean copyFileImpl(CopyFileParams fileParams, File file, String destination){ private boolean copyFileImpl(CopyFileParams fileParams, File file, String destination){
LOG.debug(fileParams.toString());
if (fileParams.getFilePartData().length > 256*1024) {
return false;
}
FileOutputStream fos; FileOutputStream fos;
String key = fileParams.getFilename() + fileParams.getCopyStartTime(); String key = fileParams.getFilename() + fileParams.getCopyStartTime();
@ -1989,11 +1992,11 @@ public class OsmandAidlApi {
file.renameTo(app.getAppPath(destination + fileParams.getFilename())); file.renameTo(app.getAppPath(destination + fileParams.getFilename()));
return true; return true;
} else if (file.length() == fileParams.getSentSize()) { } else {
fos.write(fileParams.getFilePartData()); fos.write(fileParams.getFilePartData());
return true; return true;
} }
return false;
} else { } else {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
fos = new FileOutputStream(file, true); fos = new FileOutputStream(file, true);

View file

@ -5,14 +5,12 @@ import android.os.Parcelable;
public class CopyFileParams implements Parcelable { public class CopyFileParams implements Parcelable {
private String filename; private String filename;
private long sentSize;
private byte[] filePartData; private byte[] filePartData;
private long copyStartTime; private long copyStartTime;
private boolean isTransmitComplete; private boolean isTransmitComplete;
public CopyFileParams(String filename, long sentSize, byte[] filePartData, long copyStartTime, boolean isTransmitComplete) { public CopyFileParams(String filename, byte[] filePartData, long copyStartTime, boolean isTransmitComplete) {
this.filename = filename; this.filename = filename;
this.sentSize = sentSize;
this.filePartData = filePartData; this.filePartData = filePartData;
this.copyStartTime = copyStartTime; this.copyStartTime = copyStartTime;
this.isTransmitComplete = isTransmitComplete; this.isTransmitComplete = isTransmitComplete;
@ -22,9 +20,6 @@ public class CopyFileParams implements Parcelable {
return filename; return filename;
} }
public long getSentSize() {
return sentSize;
}
public byte[] getFilePartData() { public byte[] getFilePartData() {
return filePartData; return filePartData;
@ -39,7 +34,6 @@ public class CopyFileParams implements Parcelable {
protected CopyFileParams(Parcel in) { protected CopyFileParams(Parcel in) {
filename = in.readString(); filename = in.readString();
sentSize = in.readLong();
filePartData = in.createByteArray(); filePartData = in.createByteArray();
copyStartTime = in.readLong(); copyStartTime = in.readLong();
isTransmitComplete = in.readByte() != 0; isTransmitComplete = in.readByte() != 0;
@ -66,7 +60,6 @@ public class CopyFileParams implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(filename); dest.writeString(filename);
dest.writeLong(sentSize);
dest.writeByteArray(filePartData); dest.writeByteArray(filePartData);
dest.writeLong(copyStartTime); dest.writeLong(copyStartTime);
dest.writeByte((byte) (isTransmitComplete ? 1 : 0)); dest.writeByte((byte) (isTransmitComplete ? 1 : 0));
@ -74,7 +67,7 @@ public class CopyFileParams implements Parcelable {
@Override @Override
public String toString() { public String toString() {
return "Filename: " + filename + ", sentSize = " + sentSize + ", filePartData size = " + return "Filename: " + filename + ", filePartData size = " +
filePartData.length + ", startTime: " + copyStartTime + ", isTransmitComplete: "+ isTransmitComplete; filePartData.length + ", startTime: " + copyStartTime + ", isTransmitComplete: "+ isTransmitComplete;
} }
} }