diff --git a/.gitignore b/.gitignore
index a5b5e8f..32bcbc8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
/target/
.DS_Store
/MangranaCommons.iml
+/tokens/
+/src/main/resources/credentials.json
diff --git a/pom.xml b/pom.xml
index 98400a2..d7039b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
tv.mangrana
mangrana-commons
- 4.1.0
+ 4.1.3
8
diff --git a/src/main/java/tv/mangrana/google/api/client/gateway/GoogleDriveApiGateway.java b/src/main/java/tv/mangrana/google/api/client/gateway/GoogleDriveApiGateway.java
index 5c0584c..91f2ca1 100644
--- a/src/main/java/tv/mangrana/google/api/client/gateway/GoogleDriveApiGateway.java
+++ b/src/main/java/tv/mangrana/google/api/client/gateway/GoogleDriveApiGateway.java
@@ -114,15 +114,26 @@ public class GoogleDriveApiGateway {
.execute();
}
- public void moveFile(File file, String destinationFolderId, String newName) throws IOException {
+ public void moveFile(File file, String destinationFolderId, String newFileName) throws IOException {
+ String parentId = getParent(file.getId());
File newFileReference = new File();
- newFileReference.setName(newName);
+ newFileReference.setName(newFileName);
service.files()
.update(file.getId(), newFileReference)
+ .setSupportsTeamDrives(true)
.setAddParents(destinationFolderId)
- .setRemoveParents(file.getParents().get(0))
+ .setRemoveParents(parentId)
+ .setFields("id, name, parents")
+ .execute();
+ }
+
+ private String getParent(String fileId) throws IOException {
+ File file = service.files()
+ .get(fileId)
+ .setFields("parents")
.setSupportsTeamDrives(true)
.execute();
+ return file.getParents().get(0);
}
public File createFolder(String name, String parentFolderId) throws IOException {
diff --git a/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java b/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java
index 9f149fd..a61715c 100644
--- a/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java
+++ b/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java
@@ -95,7 +95,12 @@ public class PlexCommandLauncher {
private String getPlexRefreshURL(String fullDestinationPath, String plexMountPath) {
try {
String sectionId = sectionResolver.resolveSectionByPath(fullDestinationPath, plexMountPath);
- if (sectionId==null) return null;
+ if (sectionId==null) {
+ log("Could not resolve the section of the element in plex for "+fullDestinationPath);
+ return null;
+ } else {
+ log("Captured section <{0}> of the element in plex for {1}", sectionId, fullDestinationPath);
+ }
String host = config.getConfig(PLEX_HOST);
String uriFormat = config.getConfig(PLEX_SECTION_REFRESH_URI);
String uri = uriFormat.replaceFirst("\\{section_id}", sectionId);
diff --git a/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java b/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java
index 737405f..eecb1f1 100644
--- a/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java
+++ b/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java
@@ -36,7 +36,7 @@ public class PlexLibrarySectionsResolver {
String directoryNodeOfLocation = getDirectoryKeyValue(sectionsInfo, xPath, startingLocationText);
if (directoryNodeOfLocation == null) {
startingLocationText = plexMountPath.concat("/").concat(keyFolder);
- Output.log("but going to retry with {0}", startingLocationText);
+ //Output.log("but going to retry with {0}", startingLocationText);
return getDirectoryKeyValue(sectionsInfo, xPath, startingLocationText);
} else
return directoryNodeOfLocation;
@@ -49,7 +49,7 @@ public class PlexLibrarySectionsResolver {
Node directoryNodeOfLocation = candidatesNodes.item(0).getParentNode();
return ((DeferredElementImpl) directoryNodeOfLocation).getAttribute("key");
} catch (XPathExpressionException | NullPointerException e) {
- Output.log("could not resolve the section of the element in plex "+startingLocationText);
+ //Output.log("could not resolve the section of the element in plex "+startingLocationText);
}
return null;
}