| 67 | } |
| 68 | |
| 69 | bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus, SyncthingEventId eventId, DateTime time) |
| 70 | { |
| 71 | // handle obsoletion of out-of-sync items: no FolderErrors are accepted older than the last "sync" state are accepted |
| 72 | if (newStatus == SyncthingDirStatus::PreparingToSync || newStatus == SyncthingDirStatus::Synchronizing) { |
| 73 | // update time of last "sync" state and obsolete currently assigned errors |
| 74 | lastSyncStartedEvent = eventId; |
| 75 | lastSyncStartedTime = time; // used internally and not displayed, hence keep it GMT |
| 76 | itemErrors.clear(); |
| 77 | pullErrorCount = 0; |
| 78 | } else if (lastSyncStartedTime.isNull() && newStatus != SyncthingDirStatus::OutOfSync) { |
| 79 | // prevent adding new errors from "before the first status" if the time of the last "sync" state is unknown |
| 80 | lastSyncStartedEvent = eventId; |
| 81 | lastSyncStartedTime = time; |
| 82 | } |
| 83 | |
| 84 | // clear global error if not out-of-sync anymore |
| 85 | if (newStatus != SyncthingDirStatus::OutOfSync) { |
| 86 | globalError.clear(); |
| 87 | } |
| 88 | |
| 89 | // consider the directory still as out-of-sync if there are still pull errors |
| 90 | // note: Syncthing reports status changes to "idle" despite pull errors. This means we can only rely on reading |
| 91 | // a "FolderSummary" event without pull errors for clearing the out-of-sync status. |
| 92 | if (pullErrorCount && (newStatus == SyncthingDirStatus::Unknown || newStatus == SyncthingDirStatus::Idle)) { |
| 93 | newStatus = SyncthingDirStatus::OutOfSync; |
| 94 | } |
| 95 | |
| 96 | if (newStatus == status) { |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | // update last scan time if the previous status was scanning |
| 101 | if (status == SyncthingDirStatus::Scanning) { |
| 102 | // FIXME: better use \a time and convert it from GMT to local time |
| 103 | lastScanTime = DateTime::now(); |
| 104 | } |
| 105 | |
| 106 | status = newStatus; |
| 107 | return true; |
| 108 | } |
| 109 | |
| 110 | /*! |
| 111 | * \brief Assigns the status from the specified status string. |