Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117803203
D5823.1775269260.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D5823.1775269260.diff
View Options
diff --git a/src/app/DataMigrator/Driver/DAV.php b/src/app/DataMigrator/Driver/DAV.php
--- a/src/app/DataMigrator/Driver/DAV.php
+++ b/src/app/DataMigrator/Driver/DAV.php
@@ -14,11 +14,12 @@
use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Item;
use App\DataMigrator\Interface\ItemSet;
+use App\DataMigrator\Interface\FetchItemSetInterface;
use App\User;
use App\Utils;
use Illuminate\Http\Client\RequestException;
-class DAV implements ExporterInterface, ImporterInterface
+class DAV implements ExporterInterface, ImporterInterface, FetchItemSetInterface
{
/** @var int Max number of items to migrate in one go */
protected const CHUNK_SIZE = 25;
@@ -207,22 +208,13 @@
// NOP
}
- /**
- * Fetching an item
- */
- public function fetchItem(Item $item): void
+ private function setItemFromResult(Item $item, $result): void
{
- $result = $this->client->getObjects(dirname($item->id), $this->type2DAV($item->folder->type), [$item->id]);
-
- if ($result === false) {
- throw new \Exception("Failed to fetch DAV item for {$item->id}");
- }
-
// Make the item compatible with standards (and Cyrus DAV) if possible
// We try to prevent the event to be not accepted by the DAV server as much as we can.
- $result[0]->repair();
+ $result->repair();
- $content = (string) $result[0];
+ $content = (string) $result;
if (strlen($content) > Engine::MAX_ITEM_SIZE) {
// Save the item content to a file
@@ -239,6 +231,48 @@
}
}
+ /**
+ * Fetching an item
+ */
+ public function fetchItem(Item $item): void
+ {
+ \Log::info("fetchItem: " . $item->id);
+ $result = $this->client->getObjects(dirname($item->id), $this->type2DAV($item->folder->type), [$item->id]);
+
+ if ($result === false) {
+ throw new \Exception("Failed to fetch DAV item for {$item->id}");
+ }
+
+ $this->setItemFromResult($item, $result[0]);
+
+ }
+ public function fetchItemSet(ItemSet $set, $callback): void
+ {
+ if (empty($set->items)) {
+ \Log::info("Empty set");
+ return;
+ }
+
+ $folder = dirname($set->items[0]->id);
+ $type = $this->type2DAV($set->items[0]->folder->type);
+ $ids = [];
+ foreach ($set->items as $item) {
+ $ids[] = $item->id;
+ }
+
+ $result = $this->client->getObjects($folder, $type, $ids);
+
+ if ($result === false) {
+ throw new \Exception("Failed to fetch DAV items for {$folder}");
+ }
+
+ for ($i = 0; $i < count($result); $i++) {
+ $item = $set->items[$i];
+ $this->setItemFromResult($item, $result[$i]);
+ $callback($item);
+ }
+ }
+
/**
* Fetch a list of folder items
*/
diff --git a/src/app/DataMigrator/Driver/Kolab.php b/src/app/DataMigrator/Driver/Kolab.php
--- a/src/app/DataMigrator/Driver/Kolab.php
+++ b/src/app/DataMigrator/Driver/Kolab.php
@@ -7,13 +7,15 @@
use App\DataMigrator\Engine;
use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ImporterInterface;
+use App\DataMigrator\Interface\FetchItemSetInterface;
use App\DataMigrator\Interface\Item;
+use App\DataMigrator\Interface\ItemSet;
use App\User;
/**
* Data migration from/to a Kolab server
*/
-class Kolab extends IMAP
+class Kolab extends IMAP implements FetchItemSetInterface
{
protected const CTYPE_KEY = '/shared/vendor/kolab/folder-type';
protected const CTYPE_KEY_PRIVATE = '/private/vendor/kolab/folder-type';
@@ -178,6 +180,18 @@
}
}
+ public function fetchItemSet(ItemSet $set, $callback): void
+ {
+ if (in_array($set->items[0]->folder->type, self::DAV_TYPES)) {
+ $this->davDriver->fetchItemSet($set, $callback);
+ } else {
+ foreach ($set->items as $item) {
+ $this->fetchItem($item);
+ $callback($item);
+ }
+ }
+ }
+
/**
* Fetching an item
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 4, 2:21 AM (1 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18827759
Default Alt Text
D5823.1775269260.diff (4 KB)
Attached To
Mode
D5823: Fetch dav items in batches
Attached
Detach File
Event Timeline