Skip to content

CreateDirectoriesRecursive with budged#17530

Closed
carlopi wants to merge 4 commits intoduckdb:v1.3-ossivalisfrom
carlopi:recursive_directory_limited
Closed

CreateDirectoriesRecursive with budged#17530
carlopi wants to merge 4 commits intoduckdb:v1.3-ossivalisfrom
carlopi:recursive_directory_limited

Conversation

@carlopi
Copy link
Contributor

@carlopi carlopi commented May 18, 2025

Currently:

SET home_directory = 'nonsense';
FROM duckdb_extensions();

fails like:

Can't find the home directory at 'nonsense'
Specify a home directory using the SET home_directory='/path/to/dir' option.

while after this PR it succeeds in listing extensions.

This is handy in the context of DuckDB-Wasm, where some custom code-path can be simplified (concept of home_directory is somewhat different).

LOAD and INSTALL path remains similar, in the sense that it needs a valid extension_directory OR a valid home-directory to be set, but now message is not thrown by DefaultExtensionFolder but by CreateDirectoriesRecursive.

Relevant functionality was added in #17316.

carlopi added 4 commits May 18, 2025 11:25
…g too deep

Also move error from looking up home folder to actually creating directories in the home folder.
Basically listing extensions will now succeed even with non-existing home folder or with explicit extension_directory set in a non-existing folder, while
INSTALL of extension will not fail avoiding to create the relevant directory structure.
@duckdb-draftbot duckdb-draftbot marked this pull request as draft May 18, 2025 09:50
@carlopi carlopi marked this pull request as ready for review May 18, 2025 09:50
Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I think the code in its current state seems like a bit of a band-aid fix that is not very readable. Let's try to avoid pushing changes into the file system unnecessarily and leave CreateDirectoriesRecursive alone - I think we can handle this in a cleaner way in the extension helper. My suggestion would be as follows:

}

duckdb::string ExtensionHelper::DefaultExtensionFolder(FileSystem &fs) {
duckdb::pair<duckdb::string, idx_t> ExtensionHelper::DefaultExtensionFolder(FileSystem &fs) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps instead of tracking a "how_deep" variable, we can decompose the extension folder we return here:

struct ExtensionFolder {
    string base_directory;
    vector<string> components;

    string GetPath(); // join the components together
};

Then we can call CreateDirectoriesRecursive on the components later on in the process.

@carlopi
Copy link
Contributor Author

carlopi commented Nov 7, 2025

This is now outdated, and need some adjusting. If the need arise it can be picked up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants