1<?
php declare(strict_types=1);
26 protected const DATA =
'data';
51 bool $determine_linking_possible =
false
53 $this->fs = $filesystem;
56 if ($determine_linking_possible) {
63 $random_filename =
"test_" . random_int(10000, 99999);
67 $cleaner =
function () use ($original_filename, $linked_filename) {
69 $this->fs->delete($original_filename);
70 }
catch (\Throwable $t) {
73 $this->fs->delete($linked_filename);
74 }
catch (\Throwable $t) {
83 $this->fs->write($original_filename,
'data');
84 $stream = $this->fs->readStream($original_filename);
87 $original_absolute_path = $stream->getMetadata(
'uri');
88 $linked_absolute_path = dirname($original_absolute_path) .
"/" . $random_filename .
'_link';
92 $linking = @link($original_absolute_path, $linked_absolute_path);
94 $unlinking = @unlink($original_absolute_path);
96 if ($linking && $unlinking && $this->fs->has($linked_filename)) {
102 }
catch (\Throwable $t) {
126 return $this->fs->readStream($this->
getRevisionPath($revision) .
'/' . self::DATA);
133 $DIC->upload()->moveOneFileTo($revision->
getUpload(), $this->getRevisionPath($revision), $this->location,
147 $this->fs->writeStream($this->
getRevisionPath($revision) .
'/' . self::DATA, $stream);
150 $target = $revision->
getStream()->getMetadata(
'uri');
151 if ($this->links_possible) {
161 }
catch (\Throwable $t) {
172 $this->fs->writeStream($this->
getRevisionPath($revision) .
'/' . self::DATA, $stream);
174 }
catch (\Throwable $t) {
188 }
catch (\Throwable $t) {
201 }
catch (\Throwable $t) {
205 }
catch (\Throwable $t) {
214 $first_level = strtok($container_path,
"/");
215 if (!empty($first_level)) {
216 $full_first_level = $storage_path .
'/' . $first_level;
217 $number_of_files = $this->fs->finder()->files()->in([$full_first_level])->count();
218 if ($number_of_files === 0) {
219 $this->fs->deleteDir($full_first_level);
241 return $this->path_generator->getPathFor($identification);
252 return $this->links_possible ?
'link' :
'rename';
An exception for terminatinating execution or to throw for unit testing.
Class LegacyPathHelper The legacy path helper provides convenient functions for the integration of th...
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
Interface Identification.
Class UniqueIDIdentificationGenerator.
Class UploadedFileRevision.
Class UploadedFileRevision.
Class AbstractFileSystemStorageHandler.
__construct(Filesystem $filesystem, int $location=Location::STORAGE, bool $determine_linking_possible=false)
getContainerPathWithoutBase(ResourceIdentification $identification)
This is only the path of a ResourceIdentification inside the StorageLocation base path.
cloneRevision(CloneRevision $revision)
storeStream(FileStreamRevision $revision)
@inheritDoc
has(ResourceIdentification $identification)
getBasePath(ResourceIdentification $identification)
deleteResource(StorableResource $resource)
@inheritDoc
getIdentificationGenerator()
@inheritDoc
getStream(Revision $revision)
@inheritDoc
getRevisionPath(Revision $revision)
This is the full path to a revision of a Resource, incl.
getFullContainerPath(ResourceIdentification $identification)
This is the full path to the container of a ResourceIdentification (incl.
deleteRevision(Revision $revision)
@inheritDoc
storeUpload(UploadedFileRevision $revision)
getAbsoluteRevisionPath(Revision $revision)
cleanUpContainer(StorableResource $resource)
This checks if there are empty directories in the filesystem which can be deleted.
const STORAGE
The filesystem outside of the ilias web root.
Interface Filesystem The filesystem interface provides the public interface for the Filesystem servic...
Interface FileStream The base interface for all filesystem streams.
Class UniqueIDIdentificationGenerator.
Interface StorageResource.
Class FileResourceHandler.
getStorageLocationBasePath()
This is the place in the filesystem where the containers (nested) get created.
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...