Problem

Described here #2629120: After entity was removed the file should be removed too. After that I've applied all necessary patches.
Also some comments from #2479523: Add a hook_file_stream_wrapper_uri_normalize_alter() hook look related: https://www.drupal.org/node/2479523#comment-10098768 together with https://www.drupal.org/node/2479523#comment-10098928.

Reason (possible?)

While applying the patch for File Entity, I've noticed that neither amazons3_file_entity_upload_destination_uri_alter nor amazons3_file_stream_wrapper_uri_normalize_alter appear in 7.x-1.x while they are in place in 7.x-2.x - but they both look required as otherwise patches listed at project main page are meaningless: they are both implementations of hooks added by the forementioned patches, so it looks suspicious that they are missing.

Solution

Backport amazons3_file_entity_upload_destination_uri_alter & amazons3_file_stream_wrapper_uri_normalize_alter.

Comments

PatchRanger created an issue. See original summary.

PatchRanger’s picture

Priority: Normal » Major

Marking as major as it leads to needless costs.

PatchRanger’s picture

Status: Active » Closed (won't fix)

It is better to upgrade to 7.x-2.x: https://www.drupal.org/node/2629120#comment-10690542 .

PatchRanger’s picture

Project: AmazonS3 » File Entity Paths
Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Closed (won't fix) » Needs review
StatusFileSize
new510 bytes

I've finally debugged it completely. It is integration issue which relates to AmazonS3, File Entity & File Entity Paths. Now it became clear that it's more File Entity Paths issue. Let me explain: AmazonS3 considers a file path as bucket & filename as key, default File Entity Paths configurations leaves file path empty, it leads to file paths like public:///image.jpg (note triple slash) - they are not valid filenames, unlink silently fails.
I've tried changing file path composing, avoiding redundant slash (so paths became like public://image.jpg) - it didn't help. Looks like AmazonS3 requires not empty file path.
Attaching patch, which changes default config, please review. It (together with patch from #2629120: After entity was removed the file should be removed too: https://www.drupal.org/node/2629120#comment-10703864) fixes the issue.

PatchRanger’s picture

StatusFileSize
new510 bytes

Misnamed the previous patch, correcting.

sgdev’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#2969080: Support S3 File System module

Have been using this patch without issue, thanks.

Also related is a patch we created for the S3 File System module which uses this same code: https://www.drupal.org/project/fe_paths/issues/2969080