This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flatten structure of file-layout inside the export dir.
Before this PR all data-types (files, versions, trashbin...) were stored inside a single files directory which closely followed ownClouds home-folder layout. This allowed for fast iteration but also coupled the format to ownCloud which in turn introduced some design quirks (/files/files/) in files.jsonl (#111) All data type specific folders are now stored in the root directory of the export which allows simpler mapping from metadata (#118). This is also reflected in the architecture: The exporter traverses down from the specific directories instead from the home. A special "root folder" was introduced in files.jsonl to further decouple things from owncloud and to be able to carry the e-tag for the whole tree. Instead of "/files", "/" is now root in the export. Path class has been added to reduce path-merging boilerplate.
- Loading branch information
Showing
17 changed files
with
282 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* @author Ilja Neumann <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2019, ownCloud GmbH | ||
* @license GPL-2.0 | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General, | ||
* Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
namespace OCA\DataExporter\Utilities; | ||
|
||
class Path { | ||
const REGEX = '#/+#'; | ||
|
||
/** | ||
* Joins paths, removes duplicate and adds missing slashes. Preservers | ||
* double slashes in the scheme part of the path e.g vfs://foo/bar | ||
* | ||
* @return string | ||
*/ | ||
public static function join() { | ||
$paths = []; | ||
|
||
foreach (\func_get_args() as $arg) { | ||
if ($arg !== '') { | ||
$paths[] = $arg; | ||
} | ||
} | ||
|
||
if (\count($paths) === 0) { | ||
return ''; | ||
} | ||
|
||
$firstPart = $paths[0]; | ||
$path = \preg_replace(self::REGEX, '/', \join('/', $paths)); | ||
$scheme = \parse_url($firstPart, PHP_URL_SCHEME); | ||
$hasScheme = \substr($firstPart, 0, \strlen("$scheme://")) === "$scheme://"; | ||
$slashWasRemoved = \substr($path, 0, \strlen("$scheme:/")) == "$scheme:/"; | ||
|
||
if ($hasScheme && $slashWasRemoved) { | ||
$path = "$scheme://" . \substr($path, \strlen("$scheme:/")); | ||
} | ||
|
||
return $path; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{"type":"folder","path":"\/files","eTag":"5bc8867cc2375","permissions":31,"mtime":1565124588} | ||
{"type":"folder","path":"\/files\/AFolder","eTag":"5bc8867cc2375","permissions":31,"mtime":1565124588} | ||
{"type":"file","path":"\/files\/AFolder\/afile.txt","eTag":"533c8d4b4c45b62e68cc09e810db7a23","permissions":27,"mtime":1565124588} | ||
{"type":"file","path":"\/files\/welcome.txt","eTag":"84131779d95429f06405840e136babc2","permissions":27,"mtime":1565124588} | ||
{"type":"folder","path":"\/","eTag":"5bc8867cc2375","permissions":31,"mtime":1565124588} | ||
{"type":"folder","path":"\/AFolder","eTag":"5bc8867cc2375","permissions":31,"mtime":1565124588} | ||
{"type":"file","path":"\/AFolder\/afile.txt","eTag":"533c8d4b4c45b62e68cc09e810db7a23","permissions":27,"mtime":1565124588} | ||
{"type":"file","path":"\/welcome.txt","eTag":"84131779d95429f06405840e136babc2","permissions":27,"mtime":1565124588} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.