Page MenuHomePhorge

D4956.1775372372.diff
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

D4956.1775372372.diff

diff --git a/bin/inspect.php b/bin/inspect.php
--- a/bin/inspect.php
+++ b/bin/inspect.php
@@ -41,6 +41,38 @@
// include global functions from Roundcube Framework
require_once 'Roundcube/bootstrap.php';
+
+function filterTypeToIMAPSearch($filter_type = 0)
+{
+ switch ($filter_type) {
+ case 1:
+ $mod = '-1 day';
+ break;
+ case 2:
+ $mod = '-3 days';
+ break;
+ case 3:
+ $mod = '-1 week';
+ break;
+ case 4:
+ $mod = '-2 weeks';
+ break;
+ case 5:
+ $mod = '-1 month';
+ break;
+ }
+
+ if (!empty($mod)) {
+ $dt = new DateTime('now', new DateTimeZone('UTC'));
+ $dt->modify($mod);
+ // RFC3501: IMAP SEARCH
+ return 'SINCE ' . $dt->format('d-M-Y');
+ }
+
+ return "";
+}
+
+
$opts = rcube_utils::get_opt([
'e' => 'email',
'p' => 'adminpassword',
@@ -163,17 +195,23 @@
$result[$device_id]['folders'][$folder['id']] = [
"counter" => $data['counter'],
"lastsync" => $data['lastsync'],
- "lastfiltertype" => $data['lastfiltertype'] ?? null,
"modseq" => $data['extra_data'] ? json_decode($data['extra_data'])->modseq : null,
];
}
$result[$device_id]['folders'][$folder['id']]['name'] = $folder['displayname'];
+ $result[$device_id]['folders'][$folder['id']]['class'] = $folder['class'];
+ $result[$device_id]['folders'][$folder['id']]['lastfiltertype'] = $folder['lastfiltertype'] ?? null;
$imap->select($folder['displayname']);
$result[$device_id]['folders'][$folder['id']]['imapModseq'] = $imap->data['HIGHESTMODSEQ'] ?? null;
- $index = $imap->search($folder['displayname'], 'ALL UNDELETED', false, ['COUNT']);
+ $index = $imap->search(
+ $folder['displayname'],
+ 'ALL UNDELETED ' . filterTypeToIMAPSearch($folder['lastfiltertype']),
+ false,
+ ['COUNT']
+ );
if (!$index->is_error()) {
$result[$device_id]['folders'][$folder['id']]['imapMessagecount'] = $index->count();
}
@@ -200,21 +238,44 @@
}
function filterType($value) {
- if (!$value) {
- return "No filter";
- }
- switch($value) {
- case 0: return "No filter";
- case 1: return "1 day";
- case 2: return "3 days";
- case 3: return "1 week";
- case 4: return "2 weeks";
- case 5: return "1 month";
- case 6: return "3 months";
- case 7: return "6 months";
- case 8: return "Filter by incomplete tasks";
- }
- return "Unknown value: $value";
+ if (!$value) {
+ return "No filter";
+ }
+ switch($value) {
+ case 0: return "No filter";
+ case 1: return "1 day";
+ case 2: return "3 days";
+ case 3: return "1 week";
+ case 4: return "2 weeks";
+ case 5: return "1 month";
+ case 6: return "3 months (WARNING: not implemented)";
+ case 7: return "6 months (WARNING: not implemented)";
+ case 8: return "Filter by incomplete tasks";
+ }
+ return "Unknown value: $value";
+}
+
+function getContentUids($db, $device_id, $folder_id) {
+ $contentSelect = $db->query(
+ "SELECT contentid FROM `syncroton_content`"
+ . " WHERE `device_id` = ? AND `folder_id` = ? AND `is_deleted` = 0",
+ $device_id, $folder_id
+ );
+
+ $contentUids = [];
+ while ($content = $db->fetch_assoc($contentSelect)) {
+ $contentUids[] = explode('::', $content['contentid'])[1];
+ }
+ return $contentUids;
+}
+
+function getImapUids($imap, $folder, $lastfiltertype) {
+ $imap->select($folder);
+ $index = $imap->search($folder, 'ALL UNDELETED ' . filterTypeToIMAPSearch($lastfiltertype), true);
+ if (!$index->is_error()) {
+ return $index->get();
+ }
+ return [];
}
println("");
@@ -239,6 +300,39 @@
println(" Last sync: " . ($folder['lastsync'] ?? "None"));
println(" Number of syncs: " . ($folder['counter'] ?? "None"));
println(" Filter type: " . filterType($folder['lastfiltertype'] ?? null));
+
+ if (($folder['class'] == "Email") && ($folder['counter'] ?? false) && $messageCount != $totalCount && ($modseq == "none" || $modseq == $imapModseq)) {
+ if (($folder['lastfiltertype'] ?? false) && $messageCount > $totalCount) {
+ // This doesn't have to indicate an issue, since the timewindow of the filter wanders, so some messages that have been synchronized may no longer match the window.
+ } else {
+ println(" Issue Detected: The sync state seems to be inconsistent. The device should be fully synced, but the sync counts differ.");
+ println(" There are $messageCount ContentParts (should match number of messages on the device), but $totalCount messages in IMAP matching the filter.");
+
+ $contentUids = getContentUids($db, $deviceId, $folderId);
+ $imapUids = getImapUids($imap, $folder['name'], $folder['lastfiltertype'] ?? null);
+
+ $entries = array_diff($imapUids, $contentUids);
+ if (!empty($entries)) {
+ println(" The following messages are on the server, but not the device:");
+ foreach ($entries as $uid) {
+ println(" $uid");
+ //TODO get details from imap?
+ }
+ }
+
+ $entries = array_diff($contentUids, $imapUids);
+ if (!empty($entries)) {
+ println(" The following messages are on the device, but not the server:");
+ foreach ($entries as $uid) {
+ println(" $uid");
+ //TODO get details from the content part?
+ //TODO display creation_synckey?
+ }
+ }
+ println("");
+ }
+ }
+
println("");
}
}

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 6:59 AM (50 m, 20 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18832694
Default Alt Text
D4956.1775372372.diff (5 KB)

Event Timeline