Skip to content

Create a Google Drive storage integration#157

Merged
lemonsaurus merged 13 commits intolemonsaurus:mainfrom
devlarabar:lara/google-drive
Feb 13, 2025
Merged

Create a Google Drive storage integration#157
lemonsaurus merged 13 commits intolemonsaurus:mainfrom
devlarabar:lara/google-drive

Conversation

@devlarabar
Copy link
Contributor

  • Add a new storage integration for Google Drive
  • Write tests for the Google Drive integration, similar to the ones that exist for S3 and Dropbox
  • The default destination for backups is the root folder
  • Add google-api-python-client dependency, and adjust pyyaml dependency from "^5.3.1" to "^6.0" because 5.4.1 causes the build to fail

- Occurred when attempting to upload to the root
  folder
- Due to trailing slash confusion and running the
  `_get_and_ensure_deepest_folder_id()` method
  when no folder path was given
- Caused when the provided upload directory has
  a slash, i.e. Foo/Bar
- Solved by ensuring no leading slash in the path
@lemonsaurus lemonsaurus requested a review from Copilot February 11, 2025 10:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Copy link
Owner

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two big things before we can merge:

  1. I think there is a more elegant way to handle leading and trailing slashes than this. I'd like to see us just strip them out if they exist, as early in the chain as possible, and then we don't really need to worry about how they're handled in lower level methods. I also think we should add a test to ensure trailing or leading slashes will not fail.

  2. We need to update the README with documentation for this new feature, especially the Storage Handlers chapter. It would be good to include information like "any folders that don't exist in the backup path will be created" and what configuration we're expecting the user to set.

The user shouldn't have to stress about the format
of their upload directory input.

Let's format it correctly before doing anything
with Google Drive. Do this by stripping leading
and trailing slashes, and replacing any duplicate
slashes // with single slashes /.

That would turn this:
/Hello//World///Hello/Foo/Bar
Into this:
Hello/World/Hello/Foo/Bar

With this pretty file path, we can then make sure
the file ends up in the correct place.

And, instead of creating duplicate folders like
we were before, we first _check_ if a folder with
the provided name and parent exists. If it does,
we use that one instead.
Copy link
Owner

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good, I only had one minor stylistic nitpick.

@lemonsaurus lemonsaurus merged commit 4da0c52 into lemonsaurus:main Feb 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants