mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -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
|
// Load default match fields
|
||||||
if(!FileEditor.fileExist(Fields.matchFieldsFilename)){
|
if(!FileEditor.fileExist(Fields.matchFieldsFilename)){
|
||||||
Fields.save(Fields.matchFieldsFilename, Fields.default_match_fields);
|
Fields.save(Fields.matchFieldsFilename, Fields.default_match_fields);
|
||||||
|
FileEditor.toTheArchaicPeriod(Fields.matchFieldsFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load default pit fields
|
// Load default pit fields
|
||||||
if(!FileEditor.fileExist(Fields.pitsFieldsFilename)){
|
if(!FileEditor.fileExist(Fields.pitsFieldsFilename)){
|
||||||
Fields.save(Fields.pitsFieldsFilename, Fields.default_pit_fields);
|
Fields.save(Fields.pitsFieldsFilename, Fields.default_pit_fields);
|
||||||
|
FileEditor.toTheArchaicPeriod(Fields.pitsFieldsFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get time zone for FTP file transfer
|
// get time zone for FTP file transfer
|
||||||
|
|||||||
@@ -174,23 +174,24 @@ public class HttpSync extends Thread {
|
|||||||
|
|
||||||
TransferFile localFile = findInFileArray(localFiles, remoteFile.filename);
|
TransferFile localFile = findInFileArray(localFiles, remoteFile.filename);
|
||||||
|
|
||||||
boolean shouldUpload;
|
boolean shouldDownload;
|
||||||
|
|
||||||
// If there is no file on the sever, upload.
|
// If there is no file on the sever, upload.
|
||||||
if(localFile == null) {
|
if(localFile == null) {
|
||||||
shouldUpload = true;
|
shouldDownload = true;
|
||||||
} else {
|
} else {
|
||||||
// If the remote file is the same as the local one, do nothing.
|
// 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
|
// If the local file is updated after the remote file
|
||||||
boolean after = after(remoteFile.updated, localFile.updated);
|
boolean after = after(remoteFile.updated, localFile.updated);
|
||||||
// If the local file and remote file's upload dates are exactly the same
|
// 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);
|
downloadFile(remoteFile, serverIP);
|
||||||
// await();
|
// await();
|
||||||
Log.d(getClass().toString(), "RemoteFile: " + remoteFile.filename + ", " + remoteFile.checksum + ", " + remoteFile.updated + ": Downloaded");
|
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){
|
public static boolean createFile(String filepath){
|
||||||
if(fileExist(filepath)){
|
if(fileExist(filepath)){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user