Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/ProfileServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ public static function getFileSystem()
{
$profileId = self::getProfileId();

if (is_dir(PROFILEBASE . "$profileId/")) { // backwards compatiblity check
$profilePath = $profileId;
} else {
$profilePath = implode("/", str_split($storageId, 4));
}
// The internal adapter
$adapter = new \League\Flysystem\Adapter\Local(
// Determine root directory
PROFILEBASE . "$profileId/"
$profilePath
);

$graph = new \EasyRdf\Graph();
Expand Down
48 changes: 48 additions & 0 deletions upgrade/0.4.2/upgrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

require_once(__DIR__ . "/../../config.php");

$BASES = [
PROFILEBASE
];

foreach ($BASES as $BASE) {
foreach (scandir($BASE) as $dir) {
if ($dir === '.' || $dir === '..') {
continue;
}

$source = $BASE . DIRECTORY_SEPARATOR . $dir;

// Only process directories with a 32-character hexadecimal name
if (!is_dir($source) || !preg_match('/^[a-f0-9]{32}$/i', $dir)) {
continue;
}

// Split into 8 chunks of 4 characters
$parts = str_split($dir, 4);

// Build destination path
$destination = $BASE;
foreach ($parts as $part) {
$destination .= DIRECTORY_SEPARATOR . $part;
}

// Create parent directories
$parent = dirname($destination);
if (!is_dir($parent)) {
mkdir($parent, 0755, true);
}

$source = str_replace("//", "/", $source);
$destination = str_replace("//", "/", $destination);
// Move the directory
if (rename($source, $destination)) {
echo "Moved:\n";
echo " $source\n";
echo " -> $destination\n\n";
} else {
echo "Failed: $dir\n";
}
}
}
Loading