included move feature in gdrive
This commit is contained in:
parent
aa7c331728
commit
f8757b1206
|
@ -2,3 +2,5 @@
|
|||
/target/
|
||||
.DS_Store
|
||||
/MangranaCommons.iml
|
||||
/tokens/
|
||||
/src/main/resources/credentials.json
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>tv.mangrana</groupId>
|
||||
<artifactId>mangrana-commons</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.3</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue