dbrabon / file_adoption
Scans the public file directory for orphaned files and adopts them as managed file entities.
Installs: 61
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:drupal-module
Requires
- php: ^8.2
- drupal/core: ^10 || ^11
Requires (Dev)
- phpunit/phpunit: ^10
- dev-main
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- v1.0.1
- v1.0.0
- dev-4rp7co-codex/set-version-to-v1.2.2
- dev-codex/refactor-batchscan-and-track-progress
- dev-codex/fix-batch-scan-initialization-timeout
- dev-codex/set-version-to-v1.2.2
- dev-codex/implement-fallback-to-batch-scan-after-quick-scan-fails
- dev-codex/optimize-page-load-for-/admin/reports/file-adoption
- dev-codex/update-fileadoptionform-cache-handling
- dev-codex/update-fileadoptionform-logic-and-messages
- dev-codex/update-submitform-to-refresh-and-delete-inventory
- dev-codex/update-cache_lifetime-default-to-86400
- dev-codex/modify-file_adoption.module-to-manage-cache
- dev-codex/implement-file-adoption-logic-in-submitform
- dev-codex/update-fileadoptionform-title-display
- dev-codex/document--skip-symlinks--option-and-performance-tips
- dev-codex/implement-file-scan-caching-with-refresh-button
- dev-codex/wrap-file-operations-in-try/catch-with-logging
- dev-codex/add-batch-processing-to-submitform
- dev-codex/update-file-scanner-to-handle-symlinks
- dev-codex/wrap-directory-iteration-in-try-catch-blocks-and-log-errors
- dev-codex/add-skip_symlinks-option-to-file-adoption
- dev-codex/update-file-scanning-logic-and-tests
- dev-codex/add-return-type-hints-to-filescanner-methods
- dev-codex/update-readme--remove-obsolete-test-instructions
- dev-jiqt0t-codex/add-gpl-2.0-or-later-license-file
- dev-codex/restore-composer.json-and-update-v1.2.0-tag
- dev-codex/refactor-scanchunk-and-handle-orphan-directories
- dev-codex/update-file-adoption-form-scan-logic
- dev-codex/update-version-to-v1.1.4
- dev-codex/confirm-this-orphandirs-is-array
- dev-codex/define-found_orphans-in-scanchunk
- dev-codex/initialize-positions-array-in-scanchunk
- dev-codex/cache-directories-and-files-based-on-scan
- dev-codex/add--clear-cache--button-and-handler
- dev-codex/track-file-index-during-scanchunk
- dev-codex/track-directories-with-no-orphan-files
- dev-codex/modify-file_adoption_scan_batch_step-behavior
- dev-codex/implement-file-adoption-total-count-feature
- dev-codex/implement-ignored-files-display-in-preview
- dev-codex/store-and-adopt-shown-uris-from-hidden-field
- dev-codex/update-title-for-results_manage
- dev-codex/update-file-adoption-form-and-preview-js
- dev-codex/create-setup-script-for-drupal-environment
- dev-codex/add-dev-container-setup-for-codespaces
- dev-codex/update-readme-cron-section
- dev-codex/create-testadoptrespectslimit-method
- dev-codex/update-title-and-adjust-unit-tests
- dev-codex/implement-file-adoption-and-state-update-logic
- dev-codex/adjust-javascript-refresh-timing-and-behavior
- dev-codex/gray-out-ignored-files-and-limit-folder-depth
- dev-codex/implement-ignore-pattern-handling-for-preview
- dev-codex/update-inventorydirectories-to-limit-depth
- dev-codex/refactor-batch-scan-process-for-efficiency
- dev-codex/document-three-phase-scanning-workflow
- dev-codex/write-tests-for-inventory-functions-and-cron
- dev-codex/extend-file_adoption_cron-functionality
- dev-codex/define-new-routes-and-refactor-previewcontroller
- dev-codex/add-file-scanning-and-counting-methods
- dev-codex/add-directory-inventory-method-and-caching
- dev-codex/update-file-adoption-settings-and-form
- dev-codex/change-project-version-to-v1.1.3
- dev-codex/optimize-tree-scanning-approach
- dev-codex/create-scanchunktimeouttest-and-verify-resumptions
- dev-codex/reorder-time-limit-block-and-refine-skipping-logic
- dev-codex/review-and-fix-code-and-logic-issues
- dev-codex/update-readme-with-symbolic-link-behavior
- dev-codex/create-kernel-test-for-symlink-loop
- dev-codex/update-iterator-and-symlink-detection
- dev-codex/update-preview-without-rescan-after-config-changes
- dev-codex/modify-previewcontroller-to-use-stored-file-counts
- dev-codex/extend-file-scanning-to-track-directory-counts
- dev-codex/add-helper-to-filter-uris-and-update-form
- dev-codex/remove-webforms/--from-ignore-patterns
- dev-codex/add-running-feedback-for-batch-scan-process
- dev-codex/implement-timeout-for-quick-scan-and-trigger-batch-scan
- dev-codex/move-text-below-button-section
- dev-codex/investigate-batch-scanning-counter-issue
- dev-codex/fix-invalidargumentexception-in-form-rendering
- dev-codex/update-version-to-v1.1.0
- dev-codex/delay-public-directory-preview-and-update-ui
- dev-codex/increase-items-per-cron-run-limit
- dev-codex/improve-batch-scan-speed
- dev-codex/add-id/class-and-modify-visibility-logic
- dev-codex/add-quick-scan-and-batch-scan-buttons
- dev-codex/investigate-file-adoption-issue
- dev-codex/create-drush.services.yml-with-commands-services
- dev-codex/review-module-and-create-version-1.0.7
- dev-codex/create-scanchunkresumetest
- dev-codex/update-file-matching-logic-in-filescanner
- dev-codex/create-.openai/project.json-and-setup.sh
- dev-codex/add-quick-scan-behavior-to-readme
- dev-codex/add-file_adoption_uninstall-function
- dev-codex/update-readme.md-with-scan-time-info
- dev-codex/add-description-for-items_per_run-setting
- dev-codex/expand-readme-with-development-commands
- dev-codex/optimize-filescanner-to-use-cached-uris
- dev-codex/implement-time-limited-scan-with-fallback
- dev-codex/remove-button-disabling-on-load
- dev-codex/update-readme-with-items_per_run-setting-details
- dev-codex/persist-managed-uris-across-batch-requests
- dev-codex/update-to-v1.0.6
- dev-codex/add-new-drush-command-class
- dev-codex/implement-file-processing-with-offset-and-batch-control
- dev-codex/implement-batch-scan-process-on-form-submission
- dev-codex/cleanup-commits-for-release-1.0.5
- dev-codex/update-file_adoption.settings.yml-and-readme
- dev-codex/update-adoptfile-method-signature
- dev-codex/remove-jquery-dependency-from-preview.js
- dev-codex/add-javascript-to-disable--scan-now--button
- dev-codex/modify-adoptfiles-to-return-count-and-errors
- dev-codex/update-xsi-nonamespaceschemalocation-for-phpunit-10
- dev-codex/add-drush-command-for-duplicate-file-entities
- dev-codex/modify-submitform-to-show-failure-notice
- dev-codex/update-scan-summary-or-adjust-counting-behavior
- dev-codex/modify-loadpreview-to-handle-errors
- dev-codex/create-phpunit.xml.dist-with-standard-settings
- dev-codex/add-file-scan-progress-display
- dev-codex/combine-counting-and-preview-generation-in-directoryiterator
- dev-codex/update-documentation-for-composer-and-phpunit-setup
- dev-codex/refactor-preview-directory-iteration
- dev-codex/implement-ajax-for-file-scanning-preview
- dev-codex/suggest-max-items-per-cron-run
- dev-codex/convert-closure-to-private-method
- dev-codex/refactor-preview-generation-to-optimize-counts
- dev-codex/add-file-preview-ajax-functionality
- dev-codex/alphabetize-default-ignore-pattern
- dev-codex/create-version-1.0.1-tag-and-trigger-packagist-sync
- dev-codex/update-readme-for-user-experience
- dev-codex/add-version-identifier-to-package
- dev-codex/document-packagist-webhook-setup
- dev-codex/ignore-composer-vendor-directory
- dev-codex/add-gpl-2.0-or-later-license-file
- dev-codex/update-file_adoption.info.yml-php-constraint
- dev-codex/update-readme-with-packagist-note
- dev-codex/update-composer.json-for-kernel-tests
- dev-codex/extend-fileadoptionformtest-with-ignore-pattern
- dev-codex/update-root_count-calculation-with-ignore-patterns
- dev-codex/replace-shell-command-with-countfiles-call
- dev-codex/add-file-count-method-to-filescanner
- dev-codex/remove-/dist/-folder-and-check-.gitignore
- dev-codex/optimize-scan-for-public-directory-preview
- dev-codex/replace-scanandprocess-with-shell-based-count
- dev-codex/update-readme.md-for--items-per-cron-run--option
- dev-codex/add-tests-for-scanwithlists-and-scanandprocess
- dev-codex/optimize-scan-adoption-logic
- dev-codex/delete-relative_file-from-buildform
- dev-codex/optimize-file-counting-loop
- dev-codex/add-limit-parameter-to-filescanner
- dev-codex/update-filescanner-with-items_per_run-limit
- dev-codex/inject-file-system-service-and-add-numeric-textfield
- dev-codex/extend-file_adoption-config-with-items_per_run
- dev-codex/hide-empty-ul-in-add-to-managed-files-section
- dev-codex/update-file-counter-output
- dev-codex/remove-references-to-media-from-module
- dev-codex/create-filescannermediatest-phpunit-test
- dev-codex/update-isinmedia-query-logic
- dev-codex/review-media-url-comparison-logic
- dev-codex/fix-missing-logger.channel.file_adoption-service
- dev-codex/add-phpunit/kernel-tests-for-filescanner
- dev-codex/document-module-purpose-and-usage
- dev-codex/remove-dist/-from-version-control
- dev-codex/edit-file_adoption.settings.yml-to-add-new-field
- dev-codex/add-add_to_media-key-to-config
- dev-codex/modify-filescanner-constructor-to-accept-module_handler
- dev-codex/define-new-logger-channel-in-services.yml
- dev-codex/delete-file-and-update-.gitignore
- dev-v93965-codex/update-isinmedia-to-detect-referenced-files
- dev-codex/prevent-duplication-during-entity-adoption
- dev-codex/update-isinmedia-to-detect-referenced-files
- dev-codex/add-validation-for-media-option
- dev-codex/fix-array_map-callback-typeerror-in-fileadoptionform
- dev-codex/update-public-directory-preview-and-implement-adoption-workf
- dev-codex/remove-duplicate-header-and-add-file-count
- dev-codex/add-php-requirement-to-module
This package is auto-updated.
Last update: 2025-06-30 22:42:06 UTC
README
File Adoption is a utility module for Drupal that scans the public files directory
for files that are not tracked by Drupal's file_managed
table. Identified
"orphaned" files can be registered as managed file entities.
Installation
- Place the module in your Drupal installation, typically using Composer:
composer require dbrabon/file_adoption
or by copying the module intomodules/custom
. - Enable the module from the Extend page or with Drush:
drush en file_adoption
- Navigate to Administration → Reports → File Adoption (
/admin/reports/file-adoption
) to configure and run scans.
Configuration
The configuration form offers the following options:
- Ignore Patterns – Comma or newline separated patterns (relative to
public://
) that should be skipped when scanning. - Enable Adoption – When checked, cron will automatically adopt orphaned files using the configured settings.
- Items per cron run – Maximum number of files processed and displayed per scan or cron run. Defaults to 20.
- Skip symlinks – Enabled by default to ignore files reached through symbolic links. Disable to include them in scans.
- Inventory cache lifetime – Number of seconds to keep scan results before performing a new scan. Defaults to 86400 (24 hours).
Changes are stored in file_adoption.settings
.
Cron Integration
When Enable Adoption is active, the module's hook_cron()
implementation runs
the file scanner during cron to register any discovered orphans automatically.
If a cached inventory of scan results exists and is still within the configured
cache lifetime, cron processes items from that list before performing a new
scan. This allows large inventories to be adopted across multiple cron runs.
Manual Scanning
To run a scan on demand:
- Visit the File Adoption configuration page at
/admin/reports/file-adoption
. - Click Quick Scan for a fast scan or Batch Scan to process files using Drupal's Batch API.
- Review the results and click Adopt to create the file entities.
- If results are cached and you want a fresh scan, click Refresh inventory.
Performance Considerations
Scanning large file trees can take significant time. If manual scans time out, increase PHP's max execution time in your environment. For very large sites, prefer running scans via cron so processing occurs in the background. Use the module's Items per cron run setting to control how many files are processed in each pass.
The Public Directory Contents Preview is only built when a recent inventory is cached or results were loaded from a batch scan. If no cached inventory is available, the form skips directory scanning and displays a placeholder message instead.