Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Initial attempt to write to file may fail if directory does not exist #1061

Closed
xurizaemon opened this issue Oct 17, 2024 · 1 comment
Closed

Comments

@xurizaemon
Copy link

xurizaemon commented Oct 17, 2024

What steps does it take to reproduce the issue?

We're using Drupal Migrate to write files from a Guzzle stream source to a Fedora destination via FlySystem.

For the first instance of any directory where we write to a file path, I see an attempt to check the directory exists in Fedora logs (HEAD /media/2024-10). My notes record that this fails on initial call and succeeds on subsequent ones. (This might make sense if the first successful upload implicitly creates the directory?)

At this point I'm still debugging, but what I think happens is:

  • \Drupal\Core\File\FileSystem::prepareDirectory is called with the directory path, eg 2024-10
  • \Drupal\Core\File\FileSystem::mkdir() is called via @$this->mkdir()
  • is_dir() is used to check if the directory exists, returning FALSE if it does not
  • When does this issue occur?

If the destination file is in a subdirectory of the Fedora location, and the attempt to write is the first attempt to that subdirectory.

This may be more visible in new environments, or those which have been reset for testing (eg local dev). I was not successful in reproducing this on the sandbox environment at sandbox.islandora.ca (Drupal 10.2.7, Islandora 2.12.2).

  • Which page does it occur on?

I believe this can be reproduced on the Media file attachment form as well as from Drupal migrate, provided that the Media's File field has a directory prefix configured (eg at

  • What happens?
  • First attempt: error 403 to the Fedora adapter, "Client error: Failed to save a Fedora resource to some_dir/sample.jpg."
  • Second attempt: success
  • To whom does it occur (anonymous visitor, editor, administrator)?

User uploading a file into Fedora via Drupal interfaces.

  • What did you expect to happen?

Create the directory on the fly, and write the file.

Which version of Islandora are you using?

2.12.3

Any related open or closed issues to this bug report?

xurizaemon added a commit to xurizaemon/islandora that referenced this issue Oct 17, 2024
@xurizaemon
Copy link
Author

I cannot reproduce this on sandbox, so I'm closing this issue and will re-open if I can find steps to reproduce.

Input / thoughts welcome of course!

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

No branches or pull requests

1 participant