Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.makedirs() fails unless you put a file in the folder (shared drive) #349

Open
tristanryerparke opened this issue Jun 18, 2024 · 1 comment

Comments

@tristanryerparke
Copy link

tristanryerparke commented Jun 18, 2024

Example:

# Setup
from pydrive2.fs import GDriveFileSystem
from pydrive2.auth import GoogleAuth

settings = {
    "client_config_backend": "service",
    'service_config': {
        'client_json_dict': {
            "type": "service_account",
            "private_key_id": str(os.getenv('xxx')),
            "private_key": str(os.getenv('xxx')).replace('\\n', '\n'),
            "client_email": str(os.getenv('xxx')),
            "client_id": str(os.getenv('xxx')),
        },
    'oauth_scope': [
        'https://www.googleapis.com/auth/drive',
        'https://www.googleapis.com/auth/drive.metadata'
    ]
    }
}

g = GoogleAuth(settings=settings)
g.ServiceAuth()
shared_d_name = "xxx"

fs = GDriveFileSystem(
    shared_d_name,
    google_auth=g
)


# Example that does not recursively create folders, and no exceptions raised
folder_path = f'{shared_d_name}/test_parent/test'
fs.makedirs(folder_path)

# Example that creates the folders
folder_path = f'{shared_d_name}/test_parent2/test2'
fs.makedirs(folder_path)
with fs.open(folder_path+'hi.txt', 'w') as f:
    f.write('hi')

Easy to make and then delete the file as a workaround, but the lack of success in the first example was wierd.
Best,
T

@mjkanji
Copy link

mjkanji commented Oct 11, 2024

I'm also experiencing this. Any updates on when a fix might be inbound?

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

No branches or pull requests

2 participants