fixed a bug that prefent the cloud controller from geting the latest cloud sync

This commit is contained in:
Jannik 2017-12-13 00:07:20 +01:00
parent 42b8434a58
commit 599669f0f2
3 changed files with 59 additions and 4 deletions

View File

@ -1555,6 +1555,7 @@ public class MainWindowController {
} else {
props.setProperty("cloudService", getCloudService());
}
props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService()));
props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync()));
props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth()));
props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight()));
@ -1642,6 +1643,13 @@ public class MainWindowController {
setCloudService("");
}
try {
main.getCloudController().setFolderID(props.getProperty("folderID"), getCloudService());
} catch (Exception e) {
LOGGER.error("could not load folderID, disable cloud sync. Please contact an developer", e);
setCloudSync(false);
}
try {
setLastLocalSync(Long.parseLong(props.getProperty("lastLocalSync")));
} catch (Exception e) {

View File

@ -202,4 +202,28 @@ public class CloudController {
}
}
public String getFolderID(String cloudService) {
String folderID = "";
if (cloudService != null) {
if (cloudService.equals("GoogleDrive")) {
folderID = googleDriveController.getFolderID();
}
if (cloudService.equals("Dropbox")) {
}
}
return folderID;
}
public void setFolderID(String folderID, String cloudService) {
if (cloudService != null) {
if (cloudService.equals("GoogleDrive")) {
googleDriveController.setFolderID(folderID);
}
if (cloudService.equals("Dropbox")) {
}
}
}
}

View File

@ -116,10 +116,13 @@ public class GoogleDriveController {
.build();
}
public void main(String cemuDirectory) throws IOException {
service = getDriveService();
}
public void main(String cemuDirectory) throws IOException {
service = getDriveService();
if (getFolderID() == "" || getFolderID() == null) {
getSavegamesFolderID();
}
}
// create a folder in google drive
public void creatFolder() throws IOException {
@ -203,4 +206,24 @@ public class GoogleDriveController {
return outputFile;
}
private void getSavegamesFolderID() throws IOException {
Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder' and name = 'cemu_savegames'");
FileList files = request.execute();
try {
LOGGER.info("FolderID: " + files.getFiles().get(0).getId());
setFolderID(files.getFiles().get(0).getId());
} catch (Exception e) {
LOGGER.error("Oops, something went wrong! It seems that you have more than one folder called 'cemu_savegames'!", e);
}
}
public String getFolderID() {
return folderID;
}
public void setFolderID(String folderID) {
this.folderID = folderID;
}
}