mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-08 16:28:00 -06:00
Fix downloading new fields on tablets
This commit is contained in:
@@ -47,11 +47,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
// Load default match fields
|
||||
if(!FileEditor.fileExist(Fields.matchFieldsFilename)){
|
||||
Fields.save(Fields.matchFieldsFilename, Fields.default_match_fields);
|
||||
FileEditor.toTheArchaicPeriod(Fields.matchFieldsFilename);
|
||||
}
|
||||
|
||||
// Load default pit fields
|
||||
if(!FileEditor.fileExist(Fields.pitsFieldsFilename)){
|
||||
Fields.save(Fields.pitsFieldsFilename, Fields.default_pit_fields);
|
||||
FileEditor.toTheArchaicPeriod(Fields.pitsFieldsFilename);
|
||||
}
|
||||
|
||||
// get time zone for FTP file transfer
|
||||
|
||||
@@ -174,23 +174,24 @@ public class HttpSync extends Thread {
|
||||
|
||||
TransferFile localFile = findInFileArray(localFiles, remoteFile.filename);
|
||||
|
||||
boolean shouldUpload;
|
||||
boolean shouldDownload;
|
||||
|
||||
// If there is no file on the sever, upload.
|
||||
if(localFile == null) {
|
||||
shouldUpload = true;
|
||||
shouldDownload = true;
|
||||
} else {
|
||||
// If the remote file is the same as the local one, do nothing.
|
||||
boolean checksumsEqual = !Objects.equals(localFile.checksum, remoteFile.checksum);
|
||||
|
||||
boolean checksumsNotEqual = !Objects.equals(localFile.checksum, remoteFile.checksum);
|
||||
// If the local file is updated after the remote file
|
||||
boolean after = after(remoteFile.updated, localFile.updated);
|
||||
// If the local file and remote file's upload dates are exactly the same
|
||||
boolean datesEqual = !localFile.updated.equals(remoteFile.updated);
|
||||
boolean datesNotEqual = !localFile.updated.equals(remoteFile.updated);
|
||||
|
||||
shouldUpload = (!checksumsEqual && (after) && !datesEqual);
|
||||
shouldDownload = checksumsNotEqual && after;
|
||||
}
|
||||
|
||||
if(shouldUpload) {
|
||||
if(shouldDownload) {
|
||||
downloadFile(remoteFile, serverIP);
|
||||
// await();
|
||||
Log.d(getClass().toString(), "RemoteFile: " + remoteFile.filename + ", " + remoteFile.checksum + ", " + remoteFile.updated + ": Downloaded");
|
||||
|
||||
@@ -263,6 +263,11 @@ public final class FileEditor {
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the date modified to a long, long time ago
|
||||
public static boolean toTheArchaicPeriod(String name) {
|
||||
return new File(baseDir + name).setLastModified(0);
|
||||
}
|
||||
|
||||
public static boolean createFile(String filepath){
|
||||
if(fileExist(filepath)){
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user