Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117897352
D5370.1775374794.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D5370.1775374794.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 7:39 AM (4 h, 10 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18825057
Default Alt Text
D5370.1775374794.diff (1 KB)
Attached To
Mode
D5370: manage-subscriptions.php --dropempty
Attached
Detach File
Event Timeline