dbrabon / file_adoption
Scans the public file directory for orphaned files and adopts them as managed file entities.
Installs: 130
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:drupal-module
Requires
- php: ^8.1
Requires (Dev)
- drupal/core-dev: ^10 || ^11
- phpunit/phpunit: ^9.5 || ^10
- dev-main
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.11
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- 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-codex/refactor-ismanaged-for-batch-fetching
- dev-codex/update-default-ignore-patterns
- dev-codex/remove-public-/private/-from-ignore-patterns-and-update-v
- dev-codex/add-filter-for-private-file-paths
- dev-codex/add-managed_file_uri-field-to-file_adoption_index
- dev-codex/update-form-visibility-and-alert-behavior
- dev-codex/update-version-by-0.0.1
- dev-codex/fix-typeerror-in-filescanner-constructor
- dev-codex/add-require-dev-section-to-composer.json
- dev-codex/refactor-filescanner-and-file_adoption-module
- dev-codex/replace-ignored-references-in-tests
- dev-codex/update-default-ignore-pattern-with-public-/-prefix
- dev-codex/update-module-version-to-v1.4.1
- dev-codex/update-file-adoption-settings-and-readme
- dev-codex/modify-scanpublicfiles-to-clean-up-entries
- dev-codex/rename-fields-in-filescannertest
- dev-codex/fix-file-adoption-on-page-refresh
- dev-codex/add-button-to-run-full-scan
- dev-codex/add-description-for-enable-adoption-feature
- dev-codex/set-default-file-permanence-to-true
- dev-codex/update-package-version-to-1.4.0
- dev-codex/add-checkbox-for-temporary-adoption
- dev-codex/implement-full-scan-trigger-mechanisms
- dev-codex/remove-public-/-prefix-from-patterns
- dev-codex/decide-on-scan_interval_hours-or-cron_frequency
- dev-codex/update-readme-and-adjust-ignore-patterns
- dev-codex/extend-file_adoption_uninstall-to-clear-state
- dev-codex/add-file-scan-functionality
- dev-codex/implement-file_adoption_install-and-update-cron
- dev-codex/fix-hook_update-for-file_adoption
- dev-codex/refactor-file-scanner-usages-in-tests
- dev-codex/remove-confusing-comment-from-filescanner.php
- dev-codex/add-directory_depth-and-cron_frequency-to-settings
- dev-codex/revise-kernel-tests-and-instantiate-fileadoptionform
- dev-codex/add-alias-for-file_adoption.file_scanner
- dev-codex/add-method-check-in-adoptfile-forfile
- dev-codex/replace-file_adoption_orphans-queries
- dev-hzrx49-codex/add-filemtime-to-file-entity-creation
- dev-codex/decide-on-reintroducing-methods-in-filescanner
- dev-codex/add-filemtime-to-file-entity-creation
- dev-codex/add-strictconfigschema-to-test-classes
- dev-codex/fix-schema-errors-in-file-adoption-tests
- dev-codex/add-enable-adoption-checkbox-to-report-form
- dev-codex/add-unique-key-to-file_adoption_index.uri
- dev-codex/add-directory-depth-setting-and-functionality
- dev-codex/implement-managed-column-and-updates
- dev-codex/update-file-adoption-form-processing
- dev-codex/modify-filescanner-to-continue-scanning-orphans
- dev-codex/update-case-insensitive-file-ignoring
- dev-codex/document-php-and-composer-installation-steps
- dev-codex/add-method-to-rebuild-file_adoption_orphans
- dev-codex/add-directory_depth-setting-and-updates
- dev-codex/add-managed-column-to-file_adoption_index
- dev-ibrvpb-codex/update-file-scanning-logic-and-tests
- dev-codex/update-configuration-section-in-readme.md
- dev-codex/add-tests-for-file-adoption-form
- dev-codex/filter-and-display-uris-from-file_adoption_orphans
- dev-codex/update-directory-ignore-logic-and-ui
- dev-codex/update-fileadoptionform-to-filter-uris
- dev-codex/update-fileadoptionform-for-ignored-directories
- dev-codex/update-file-adoption-list-handling
- dev-codex/add-ignored-column-and-update-file-scanning
- dev-l4jps0-codex/setup-cron-job-for-file-system-syncing
- dev-codex/setup-cron-job-for-file-system-syncing
- dev-codex/fix-file_adoption_update_10008-error
- dev-codex/add-oembed_thumbnails-to-ignore-patterns
- dev-codex/fix-orphan-table-status-message
- dev-codex/add-recordorphanstest-in-test-suite
- dev-codex/update-php-files-for-strict-types-and-types
- dev-codex/add-typed-database-property-to-fileadoptionform
- dev-codex/turn-off-verbose-logging-by-default
- dev-codex/count-files-in-reports-page-load
- dev-codex/verify-uninstall-removes-all-artifacts
- dev-codex/refactor-complex-logic-into-methods
- dev-codex/remove-duplicated-file_adoption-header
- dev-codex/add-directory-iteration-method-to-filescanner
- dev-codex/remove-unused-methods-from-filescanner
- dev-codex/remove-unused-properties-and-services
- dev-codex/add-embed_buttons-to-ignore-patterns
- dev-codex/update-status-messages-in-fileadoptionform
- dev-codex/modify-ignore_patterns-in-file_adoption
- dev-codex/add-verbose-logging-guard-to-adoption-messages
- dev-codex/update-cron-frequency-options
- dev-codex/reformat-src/filescanner.php-for-2-space-indentation
- dev-codex/decide-if-0-represents-unlimited
- dev-codex/delete-or-define-permissions-in-file_adoption.permissions.ym
- dev-codex/create-license-file-with-gpl-2.0-or-later
- dev-codex/create-verbose-logging-by-default
- dev-codex/refactor-fileadoptionform-to-avoid-direct-filesystem-scans
- dev-codex/add-cron-frequency-configuration
- dev-codex/fix-php-parse-error-on-line-240
- dev-codex/remove-hardlink-scanning-tests-and-update-others
- dev-codex/remove-batch-scanning-and-hard-coded-links
- dev-codex/remove-file_adoption_hardlinks-handling-from-adoptfile
- dev-codex/remove-scan-buttons-and-add-cron-settings
- dev-codex/remove-hardlinkscanner-and-related-components
- dev-codex/fix-foreach-argument-type-warning
- dev-codex/implement-caching-and-update-hardlinkscanner
- dev-codex/cache-hardlinkscanner-results-with-logging
- dev-codex/fix-foreach-argument-type-error
- dev-codex/update-hardlinkscanner-and-extend-schema
- dev-codex/update-hardlinkscanner-to-inspect-all-text-columns
- dev-codex/fix-yaml-parse-errors-and-update-issues
- dev-codex/display-hard-coded-links-in-nodes-as-warnings
- dev-codex/update-schema-and-extend-tests
- dev-codex/update-file_adoption_hardlinks-schema-and-logic
- dev-codex/modify-submitform-to-handle-refresh_links-trigger
- dev-codex/create-scanandaddusage-controller-method
- dev-codex/update-iteration-for-_value-and-_uri-suffixes
- dev-codex/modify-file_adoption_hardlinks-schema-and-update-methods
- dev-codex/fix-file-usage-sync-on-cron-run
- dev-codex/update-php-version-requirement-to-8.1
- dev-codex/add-hard-coded-links-section
- dev-codex/create-kernel-test-hardlinkscannertest
- dev-codex/inject-hardlinkscanner-into-cron-logic
- dev-codex/add-usage-records-and-logging-after-file-adoption
- dev-codex/add-refresh_links-button-and-functionality
- dev-codex/create-hardlinkscanner-service
- dev-codex/extend-file_adoption_schema-and-add-update-hook
- dev-codex/refactor-filescanner-to-process-files-incrementally
- dev-codex/add-canonicalizeuri-method-and-update-cache-keys
- dev-codex/track-and-display-symlinks-in-preview
- dev-codex/fix-adopt-button-not-working-after-batch-scan
- dev-codex/fix-syntax-error-in-filescanner.php
- dev-codex/update-batch-scan-to-scan-in-chunks-of-50-files
- dev-codex/update-readme-and-create-kernel-tests
- dev-codex/add-listunmanagedrecursive-method-and-update-preview
- dev-codex/add-batch-scanning-to-fileadoptionform
- dev-codex/create-kernel-test-for-batch-process
- dev-codex/implement-directory-filter-for-unmanaged-files
- dev-codex/add-batch-scan-button-and-functionality
- dev-codex/add-batch-scan-button-and-routine
- dev-codex/fix-duplicate-file-upload-and-date-assignment
- dev-codex/add-if-statement-to-delay-execution
- dev-codex/modify-fileadoptionform-and-update-readme
- dev-8esq1b-codex/fix-file-adoption-scan-on-page-load
- dev-codex/fix-file-adoption-scan-on-page-load
- dev-codex/update-fileadoptionform-and-tests
- dev-codex/update-readme.md-for-test-execution-details
- dev-codex/update-readme-with--ignore-symlinks--setting
- dev-codex/update-readme-for-cron-integration-details
- dev-codex/add-kernel-tests-for-ignore_symlinks
- dev-codex/modify-buildform-to-query-file_adoption_orphans
- dev-codex/adjust-file_adoption_cron-to-call-scanwithlists
- dev-codex/update-filescanner-methods-to-check-islink
- dev-codex/add-ignore_symlinks-setting-to-config
- dev-codex/stop-automatic-scan-on-page-load
- dev-codex/disable-automatic-scan-on-page-load
- dev-codex/save-gathered-data-in-a-table
- dev-codex/update-preview-after-saving-changes
- dev-codex/add-troubleshooting-section-with-debug-logs-details
- dev-codex/add-testfulladoptionworkflow-to-filescannertest
- dev-5n3njm-codex/update-preview-note-and-readme-section
- dev-codex/update-preview-note-and-readme-section
- dev-codex/replace-tracked-files-and-directory-preview-sections
- dev-codex/modify-file-adoption-preview-and-sections
- dev-codex/refactor-filescanner.php-to-remove-redundancy
- dev-codex/edit-populatefrommanaged-logic
- dev-codex/retrieve-directory-filemtime-in-ensuredirectory
- dev-codex/document-pre-population-and-scanning-order
- dev-codex/implement-file_adoption_uninstall-and-drop-tables
- dev-codex/add-scan-depth-and-directory-preview-features
- dev-codex/remove-or-update-method-as-per-issue-+2
- dev-codex/query-and-display-directory-adoption-details
- dev-codex/implement-uri-reading-and-insertion-routine
- dev-codex/add-directory-preview-and-help-text
- dev-codex/extend-fileadoptionform-with-directory-preview
- dev-codex/update-ignore-pattern-handling-and-add-tests
- dev-codex/update-scan-logic-to-handle-ignore-and-managed-flags
- dev-codex/implement-ignore-logic-for-directory-scanning
- dev-codex/update-ignore-handling-in-scan-functions
- dev-codex/update-loadmanageduris-and-countmanagedfiles-logic
- dev-codex/implement-scan-with-file-management
- dev-codex/add-populatemanagedfiles-method-and-tests
- dev-codex/create-populatefrommanaged-method-in-inventorymanager
- dev-codex/remove-unused-properties-and-adjust-tests
- dev-codex/add--add-to-managed-files--section
- dev-codex/refactor-fileadoptionform-and-update-readme
- dev-codex/modify-fileadoptionform-functionality
- dev-codex/remove-cleanup-functions-and-references
- dev-codex/document-purpose-and-operations-of-tables
- dev-codex/extend-tests-for-filescannertest
- dev-codex/add-cleanup-methods-and-batch-process
- dev-codex/update-file_adoption_cron-logic
- dev-codex/update-preview-logic-and-batch-actions
- dev-codex/create-urihelper-class-and-refactor-usage
- dev-codex/refactor-filescanner-methods-and-database-logic
- dev-codex/implement-file_adoption-schema-and-hooks
- 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/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-07-22 17:34:32 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
The first cron run after installation automatically performs a full scan of
`public://`. Run `drush cron` if you want results immediately.
3. Navigate to **Administration → Reports → File Adoption** (`/admin/reports/file-adoption`)
to configure settings or review the most recent scan results. The page no
longer runs a scan automatically.
## Configuration
The configuration form offers the following options:
- **Ignore Patterns** – Comma or newline separated patterns relative to
`public://` that should be skipped when scanning. Patterns may contain simple
wildcards (`*`, `?`) which are automatically converted to regular
expressions when the form is saved. The default configuration skips
directories such as:
/. public://asset_injector/.* public://config_.* public://css/.* public://embed_buttons/.* public://favicon.ico public://js/.* public://media-icons/.* public://media-youtube/.* public://oembed_thumbnails/.* public://php/.* public://styles/.* public://webforms/.*
- Pattern matching is case-insensitive.
- **Enable Adoption** – Automatically adopts up to the number in **Items per adoption batch** during each cron run using the configured settings.
- **Items per adoption batch** – Maximum number of files adopted or displayed per
scan or cron run. All discovered orphans are saved regardless of this
limit. Defaults to 20.
- **Adopt as Temporary** – When checked, newly adopted files are saved as
temporary. Unchecked files become permanent immediately.
- **Ignore Symlinks** – When enabled, symbolic links are skipped during scanning,
preventing loops or slowdowns caused by symlinks.
Symlinks discovered during scanning are still listed under the "Symlinks"
- **Directory Depth** – Maximum directory depth displayed under "Directories".
Directories deeper than this setting are omitted from the summary but files
within them can still be adopted. Valid range is 1–9 and the default is 9.
- **Full-scan interval (hours)** – Number of hours between automatic full scans.
Set to `0` to run on every cron run. The default is 24 hours.
- **Verbose Logging** – When enabled, additional debug information is written to
the log during scans and adoption. This is off by default. Adoption success
messages are only recorded when verbose logging is enabled. When enabled,
each directory encountered during cron scans is also logged.
The configuration page also shows details gathered from the most recent scan:
- **Directories** – Lists every directory discovered. Directories marked as
ignored are annotated with “(ignored)” and any ignored file names appear in
parentheses. This information is read from the `file_adoption_index` table.
- **Add to Managed Files** – Displays the files scheduled for adoption. Entries
are pulled directly from the `file_adoption_index` table after filtering out
ignored directories and patterns.
- **Run full scan** – Button at the bottom of the form that immediately
executes a full cron-style scan of the public files directory.
Changes are stored in `file_adoption.settings`.
## Cron Integration
Scanning occurs exclusively during cron runs. Upon installation a state flag
causes the next cron run to perform an immediate full scan. The *Full-scan interval* setting
controls how often `hook_cron()` invokes the `FileScanner` service. Each run
records its totals to state so the configuration page can report the last
execution. When **Enable Adoption** is disabled the run simply updates the
`file_adoption_index` table with any discovered orphans. When adoption is
enabled, matching files are registered immediately. Every cron run rebuilds the
`file_adoption_index` table so the most current data is always available.
## Running Tests
These tests rely on Drupal's core testing environment. Install the
development dependencies with Composer so that `drupal/core-dev` and
`phpunit/phpunit` are available. Tests should be executed from the Drupal
project root so that Drupal's PHPUnit configuration is used.
From the module directory you can run:
```bash
../vendor/bin/phpunit -c core modules/custom/file_adoption
The tests are located under the tests/
directory and include kernel tests for
the FileScanner
service and the configuration form.
Uninstall
Uninstalling the module removes all configuration and drops the
file_adoption_index
table so no leftover data remains. If the table ever
contains bad data simply uninstall and reinstall the module to rebuild it.
v2.0.0 – 2025‑07‑11
- Replaced orphan tracking table – the single
file_adoption_index
table now holds everything:is_managed
→ present in file_managedis_ignored
→ matches an admin‑defined regex ignore patterndirectory_depth
→ number of “/” in the public:// relative path
- Ignore patterns accept full Perl‑compatible regular expressions and may include simple wildcards which are converted to regex when the configuration is saved.
- Cron and the “Adopt Now” button both adopt files by selecting
is_managed = 0 AND is_ignored = 0
, up to Items per adoption batch. - The admin UI pulls its Directories and Add to Managed Files sections
directly from
file_adoption_index
, so results appear even while a long full‑disk scan is still running. - Database update 10012 will:
- Drop the obsolete
file_adoption_orphans
table. - Rename old
ignored
/managed
fields if present. - Add the new
directory_depth
field.
- Drop the obsolete