Skip to content

Commit

Permalink
Merge branch 'gdrive-backups-in-root-try2-327' of https://github.com/…
Browse files Browse the repository at this point in the history
…Jackabomb/KeeAnywhere into Jackabomb-gdrive-backups-in-root-try2-327
  • Loading branch information
Kyrodan committed Jun 17, 2024
2 parents dbc5f99 + 456dc9a commit 53cb5a5
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,26 @@ public async Task Copy(string sourcePath, string destPath)
if (sourceFile == null)
throw new FileNotFoundException("Google Drive: File not found.", sourcePath);

var destFilename = CloudPath.GetFileName(destPath);
var destFolder = CloudPath.GetDirectoryName(destPath);
var parentFolder = await api.GetFileByPath(destFolder, true);
if (parentFolder == null)
throw new FileNotFoundException("Google Drive: File not found.", destFolder);

var destFilename = CloudPath.GetFileName(destPath);
var destFile = new File
{
Name = destFilename,
Parents = new[] {parentFolder.Id}
Parents = new[] { "root" }
};

if (!string.IsNullOrEmpty(destFolder))
{
var parentFolder = await api.GetFileByPath(destFolder);
if (parentFolder == null)
throw new FileNotFoundException("Google Drive: File not found.", destFolder);

destFile.Parents = new[] { parentFolder.Id };
}

var result = await api.Files.Copy(destFile, sourceFile.Id).ExecuteAsync();
}

Expand Down Expand Up @@ -157,6 +165,9 @@ public async Task<IEnumerable<StorageProviderItem>> GetChildrenByParentItem(Stor

public async Task<IEnumerable<StorageProviderItem>> GetChildrenByParentPath(string path)
{
if (string.IsNullOrEmpty(path))
return await GetChildrenByParentItem(await GetRootItem());

var api = await GetApi();
var item = await api.GetFileByPath(path, true);
if (item == null)
Expand Down

0 comments on commit 53cb5a5

Please sign in to comment.