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

Ensure parent directory exists #1062

Draft
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

xurizaemon
Copy link

GitHub Issue: #1061

What does this Pull Request do?

Create the containing directory if there is one.

What's new?

  • When writing a file to FedoraAdapter, we will attempt to create any containing directory first.

How should this be tested?

See #1061

Documentation Status

n/a?

Interested parties

@Islandora/committers

Comment on lines +301 to +305
$parts = explode('/', $path);
array_pop($parts);
if ($parts) {
$this->createDir(implode('/', $parts), $config);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of exploding/imploding, this should probably use an implementation of FileSystemInterface::dirname(), such as FileSystem::dirname(). PHP's dirname() might work; however, FileSystemInterface::dirname() indicates:

PHP's dirname() does not properly pass streams, so this function fills that gap. It is backwards compatible with normal paths and will use PHP's dirname() as a fallback.

Compatibility: normal paths and stream wrappers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes that makes more sense, silly to reinvent.

I plan to verify whether this is a real issue (seems like something that would have been discovered before now?) and come back with some repro steps to confirm.

@xurizaemon xurizaemon marked this pull request as draft October 17, 2024 19:45
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

Successfully merging this pull request may close these issues.

2 participants