Skip to content

Conversation

@nccchris
Copy link

Creates directory public://localgov_publications_importer when module is installed. Deletes public://localgov_publications_importer when module is uninstalled.

What does this change?

This change ensures that the module automatically creates the required directory public://localgov_publications_importer during installation and removes it during uninstallation.
Previously, this directory had to be created manually, which could lead to errors if forgotten. Automating this step improves reliability and reduces setup friction.
How it works:
Implements hook_install() to create the directory using Drupal’s file_system service.
Implements hook_uninstall() to remove the directory recursively.

How to test

On main:
Install the module.
Observe that public://localgov_publications_importer does not exist unless manually created.

On this branch:
Install the module.
Confirm that public://localgov_publications_importer is automatically created.
Uninstall the module.
Confirm that the directory is removed.

How can we measure success?

No manual steps required for directory creation.
No errors related to missing directory during module usage.
Clean uninstall without leaving orphaned directories.

Have we considered potential risks?

Risk: Directory deletion on uninstall could remove files if they were manually added by a site admin

Creates directory public://localgov_publications_importer when module is installed. 
Deletes public://localgov_publications_importer when module is uninstalled.
@finnlewis finnlewis self-requested a review November 18, 2025 12:40
@rupertj
Copy link
Member

rupertj commented Dec 22, 2025

There's already code to do this in the only bit of the module that uses public://localgov_publications_importer, which is the images plugin:

$fileSystem->prepareDirectory($publicDir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);

So that might not be working? Although it's almost the same as the code in this PR, so I don't get why one would work and not the other.

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.

public://localgov_publications_importer folder not created automatically.

3 participants