19declare(strict_types=1);
43 protected const DATA =
'data';
44 protected \ILIAS\ResourceStorage\StorageHandler\PathGenerator\PathGenerator
$path_generator;
45 protected \ILIAS\ResourceStorage\Identification\IdentificationGenerator
$id;
53 bool $determine_linking_possible =
false
58 if ($determine_linking_possible) {
65 $random_filename =
"test_" . random_int(10000, 99999);
69 $cleaner =
function () use ($original_filename, $linked_filename):
void {
71 $this->fs->delete($original_filename);
72 }
catch (\Throwable $exception) {
75 $this->fs->delete($linked_filename);
76 }
catch (\Throwable $exception) {
85 $this->fs->write($original_filename,
'data');
86 $stream = $this->fs->readStream($original_filename);
89 $original_absolute_path = $stream->getMetadata(
'uri');
90 $linked_absolute_path = dirname($original_absolute_path) .
"/" . $random_filename .
'_link';
94 $linking = @link($original_absolute_path, $linked_absolute_path);
96 $unlinking = @unlink($original_absolute_path);
98 if ($linking && $unlinking && $this->fs->has($linked_filename)) {
104 }
catch (\Throwable $exception) {
128 return $this->fs->readStream($this->
getRevisionPath($revision) .
'/' . self::DATA);
135 $DIC->upload()->moveOneFileTo(
137 $this->getRevisionPath($revision),
153 $this->fs->writeStream($this->
getRevisionPath($revision) .
'/' . self::DATA, $stream);
156 $original_path = $revision->
getStream()->getMetadata(
'uri');
157 if ($this->links_possible) {
160 unlink($original_path);
165 $this->fs->writeStream($this->
getRevisionPath($revision) .
'/' . self::DATA, $stream);
167 unlink($original_path);
177 }
catch (\Throwable $exception) {
188 $this->fs->writeStream($this->
getRevisionPath($revision) .
'/' . self::DATA, $stream);
190 }
catch (\Throwable $exception) {
204 }
catch (\Throwable $exception) {
215 }
catch (\Throwable $exception) {
219 }
catch (\Throwable $exception) {
227 $first_level = strtok($container_path,
"/");
228 if (!empty($first_level)) {
229 $full_first_level = $storage_path .
'/' . $first_level;
230 $number_of_files = $this->fs->finder()->files()->in([$full_first_level])->count();
231 if ($number_of_files === 0) {
232 $this->fs->deleteDir($full_first_level);
254 return $this->path_generator->getPathFor($identification);
264 return $this->links_possible ?
'link' :
'rename';
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
static deriveLocationFrom(string $absolute_path)
Class ResourceIdentification.
Class UniqueIDIdentificationGenerator.
Class UploadedFileRevision.
Class UploadedFileRevision.
Class AbstractFileSystemStorageHandler.
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)
ILIAS ResourceStorage StorageHandler PathGenerator PathGenerator $path_generator
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.
ILIAS ResourceStorage Identification IdentificationGenerator $id
getFullContainerPath(ResourceIdentification $identification)
This is the full path to the container of a ResourceIdentification (incl.
deleteRevision(Revision $revision)
@inheritDoc
storeUpload(UploadedFileRevision $revision)
__construct(Filesystem $fs, int $location=Location::STORAGE, bool $determine_linking_possible=false)
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.
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...