fix: update search attribute on storage bucket and file name changes#11871
fix: update search attribute on storage bucket and file name changes#11871yogeshwaran-c wants to merge 1 commit intoappwrite:1.9.xfrom
Conversation
The search attribute was not being updated when bucket or file names were changed via the update endpoints, causing stale search index data and making renamed buckets and files unfindable by their new names. All other modules (Databases, Functions, Sites, Teams, Projects) already update the search attribute on name changes - this aligns the Storage module with that established pattern.
Greptile SummaryThis PR fixes a bug where renaming a storage bucket or file did not update the Confidence Score: 5/5Safe to merge — the changes are minimal, correct, and consistent with the rest of the codebase. Both additions exactly replicate the No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: update search attribute on storage ..." | Re-trigger Greptile |
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
When a bucket name is updated via
PUT /v1/storage/buckets/:bucketIdor a file name is updated viaPUT /v1/storage/buckets/:bucketId/files/:fileId, thesearchattribute is not updated. This means the fulltext search index retains the old name, making renamed buckets and files unfindable by their new names.Every other module in the codebase correctly updates the
searchattribute when names change:Databases/Http/Databases/Update.php—->setAttribute('search', implode(' ', [$databaseId, $searchName]))Functions/Http/Functions/Update.php—'search' => implode(' ', [$functionId, $name, $runtime])Sites/Http/Sites/Update.php—'search' => implode(' ', [$siteId, $name, $framework])Teams/Http/Teams/Name/Update.php—->setAttribute('search', implode(' ', [$teamId, $name]))Projects/Http/Projects/Update.php—->setAttribute('search', implode(' ', [$projectId, $name]))The Storage module is the only one missing this update.
What is the new behavior?
searchattribute is now updated toimplode(' ', [$bucketId, $name])when the bucket is updated, matching the format used during bucket creation.searchattribute is now updated toimplode(' ', [$fileId, $name])when the file name is changed, matching the format used during file creation. This only happens when a new name is actually provided (thenameparameter is optional).Test plan
docker compose exec appwrite test tests/e2e/Services/Storage