Page MenuHomePhorge

D5370.1775475484.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D5370.1775475484.diff

diff --git a/bin/manage-subscription.php b/bin/manage-subscription.php
--- a/bin/manage-subscription.php
+++ b/bin/manage-subscription.php
@@ -46,17 +46,34 @@
--reset: Remove all subscriptions.
--enableall: Enable all subscriptions by looking up backend folders. Requires the user password.
--enableknown: Enable all subscriptions of folders that have been synchronized previously with syncroton.
+ --dropempty: Delete empty subscriptions, triggering a re-import from metadata.
--reinit: Re-run the initialization for new devices. Requires the user password.
EOF);
exit(0);
}
+
+$cli = new SyncrotonCli();
+
+if (!empty($opts['dropempty'])) {
+ $db = $cli->db;
+ if ($dryRun) {
+ $query = $db->query("SELECT * FROM `syncroton_subscriptions` WHERE `data` = '[]'");
+ while ($record = $db->fetch_assoc($query)) {
+ print("$dryRun {$record['device_id']} {$record['type']}\n");
+ }
+ } else {
+ $query = $db->query("DELETE FROM `syncroton_subscriptions` WHERE `data` = '[]'");
+ $affectedRows = $db->affected_rows($query);
+ print("Deleted $affectedRows empty subscriptions sets.");
+ }
+}
+
if (empty($opts['owner'])) {
\rcube::raise_error("Owner not specified (--owner).", false, true);
}
-$cli = new SyncrotonCli();
$userid = $cli->selectUser($opts['owner'] ?? null);
$devices = $cli->selectDevices($opts['deviceid'] ?? null, $opts['devicetype'] ?? null);
@@ -80,9 +97,8 @@
}
} else {
$query = $db->query("DELETE FROM `syncroton_subscriptions` WHERE `device_id` IN (" . $db->array2list($devices) . ")");
- while ($record = $db->fetch_assoc($query)) {
- print("{$record['device_id']} {$record['type']}\n");
- }
+ $affectedRows = $db->affected_rows($query);
+ print("Deleted $affectedRows subscriptions sets.");
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 6, 11:38 AM (13 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18825057
Default Alt Text
D5370.1775475484.diff (1 KB)

Event Timeline