Skip to content

Commit

Permalink
#25 prevent updating not updatable information by constructing a new …
Browse files Browse the repository at this point in the history
…File object
  • Loading branch information
siom79 committed Sep 24, 2023
1 parent dc18e31 commit 43504a2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/jdrivesync/gdrive/GoogleDriveAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.google.api.services.drive.Drive.Files.Export;
import com.google.api.services.drive.model.File;
import com.google.api.services.drive.model.FileList;
//import com.google.api.services.drive.model.ParentReference;
import jdrivesync.cli.Options;
import jdrivesync.constants.Constants;
import jdrivesync.encryption.Encryption;
Expand Down Expand Up @@ -219,9 +218,12 @@ public void updateFile(SyncItem syncItem) {
if (isGoogleAppsDocument(remoteFile)) {
return;
}
File uploadFile = new File();
uploadFile.setName(remoteFile.getName());
uploadFile.setDescription(remoteFile.getDescription());
LOGGER.log(Level.INFO, "Updating file " + remoteFile.getId() + " (" + syncItem.getPath() + ").");
if (!options.isDryRun()) {
Drive.Files.Update updateRequest = drive.files().update(remoteFile.getId(), remoteFile, new FileContent(determineMimeType(localFile), localFile));
Drive.Files.Update updateRequest = drive.files().update(remoteFile.getId(), uploadFile, new FileContent(determineMimeType(localFile), localFile));
//updateRequest.setModifiedDate(true);
File updatedFile = executeWithRetry(options, () -> updateRequest.execute());
syncItem.setRemoteFile(Optional.of(updatedFile));
Expand Down

0 comments on commit 43504a2

Please sign in to comment.