[geary/mjog/invert-folder-class-hierarchy: 71/72] engine: Remove now unused code in MinimalFolder and ImapDB.Folder
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/invert-folder-class-hierarchy: 71/72] engine: Remove now unused code in MinimalFolder and ImapDB.Folder
- Date: Wed, 3 Mar 2021 11:52:49 +0000 (UTC)
commit 9f1cf1a53745e4fc4595c3f175ab6e4f2ead2676
Author: Michael Gratton <mike vee net>
Date: Wed Mar 3 21:01:44 2021 +1100
engine: Remove now unused code in MinimalFolder and ImapDB.Folder
src/engine/imap-db/imap-db-folder.vala | 198 ---------------------
.../imap-engine/imap-engine-minimal-folder.vala | 181 -------------------
2 files changed, 379 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index 455271f2f..0653fecb6 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -510,114 +510,6 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
return results;
}
- // LoadFlags.OLDEST_TO_NEWEST is ignored. INCLUDING_ID means including *both* identifiers.
- // Without this flag, neither are considered as part of the range.
- public async Gee.List<Geary.Email>? list_email_by_range_async(ImapDB.EmailIdentifier start_id,
- ImapDB.EmailIdentifier end_id, Geary.Email.Field required_fields, LoadFlags flags, Cancellable?
cancellable)
- throws Error {
- bool including_id = flags.is_all_set(LoadFlags.INCLUDING_ID);
-
- // Break up work so all reading isn't done in single transaction that locks up the
- // database ... first, gather locations of all emails in database
- Gee.List<LocationIdentifier>? locations = null;
- yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
- // use INCLUDE_MARKED_FOR_REMOVE because this is a ranged list ...
- // do_results_to_location() will deal with removing EmailIdentifiers if necessary
- LocationIdentifier? start_location = do_get_location_for_id(cx, start_id,
- LoadFlags.INCLUDE_MARKED_FOR_REMOVE, cancellable);
- if (start_location == null)
- return Db.TransactionOutcome.DONE;
-
- Imap.UID start_uid = start_location.uid;
-
- // see note above about INCLUDE_MARKED_FOR_REMOVE
- LocationIdentifier? end_location = do_get_location_for_id(cx, end_id,
- LoadFlags.INCLUDE_MARKED_FOR_REMOVE, cancellable);
- if (end_location == null)
- return Db.TransactionOutcome.DONE;
-
- Imap.UID end_uid = end_location.uid;
-
- if (!including_id) {
- start_uid = start_uid.next(false);
- end_uid = end_uid.previous(false);
- }
-
- if (!start_uid.is_valid() || !end_uid.is_valid() || start_uid.compare_to(end_uid) > 0)
- return Db.TransactionOutcome.DONE;
-
- Db.Statement stmt = cx.prepare("""
- SELECT message_id, ordering, remove_marker
- FROM MessageLocationTable
- WHERE folder_id = ? AND ordering >= ? AND ordering <= ?
- """);
- stmt.bind_rowid(0, folder_id);
- stmt.bind_int64(1, start_uid.value);
- stmt.bind_int64(2, end_uid.value);
-
- locations = do_results_to_locations(stmt.exec(cancellable), int.MAX, flags, cancellable);
-
- return Db.TransactionOutcome.SUCCESS;
- }, cancellable);
-
- var results = new Gee.ArrayList<Email>();
- yield list_email_in_chunks_async(
- locations, results, required_fields, flags, false, cancellable
- );
- return results.is_empty ? null : results;
- }
-
- // LoadFlags.OLDEST_TO_NEWEST is ignored. INCLUDING_ID means including *both* identifiers.
- // Without this flag, neither are considered as part of the range.
- public async Gee.List<Geary.Email>? list_email_by_uid_range_async(Imap.UID start,
- Imap.UID end, Geary.Email.Field required_fields, LoadFlags flags, Cancellable? cancellable)
- throws Error {
- bool including_id = flags.is_all_set(LoadFlags.INCLUDING_ID);
- bool only_incomplete = flags.is_all_set(LoadFlags.ONLY_INCOMPLETE);
-
- Imap.UID start_uid = start;
- Imap.UID end_uid = end;
-
- if (!including_id) {
- start_uid = start_uid.next(false);
- end_uid = end_uid.previous(false);
- }
-
- if (!start_uid.is_valid() || !end_uid.is_valid() || start_uid.compare_to(end_uid) > 0)
- return null;
-
- // Break up work so all reading isn't done in single transaction that locks up the
- // database ... first, gather locations of all emails in database
- Gee.List<LocationIdentifier>? locations = null;
- yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
- StringBuilder sql = new StringBuilder("""
- SELECT MessageLocationTable.message_id, ordering, remove_marker
- FROM MessageLocationTable
- """);
-
- sql.append("WHERE folder_id = ? AND ordering >= ? AND ordering <= ? ");
-
- Db.Statement stmt = cx.prepare(sql.str);
- stmt.bind_rowid(0, folder_id);
- stmt.bind_int64(1, start_uid.value);
- stmt.bind_int64(2, end_uid.value);
-
- locations = do_results_to_locations(stmt.exec(cancellable), int.MAX, flags, cancellable);
-
- return Db.TransactionOutcome.SUCCESS;
- }, cancellable);
-
- // remove complete locations (emails with all fields downloaded)
- if (only_incomplete)
- locations = yield remove_complete_locations_in_chunks_async(locations, cancellable);
-
- var results = new Gee.ArrayList<Email>();
- yield list_email_in_chunks_async(
- locations, results, required_fields, flags, false, cancellable
- );
- return results.is_empty ? null : results;
- }
-
public async Gee.Set<Email> list_email_by_sparse_id_async(
Gee.Collection<ImapDB.EmailIdentifier> ids,
Geary.Email.Field required_fields,
@@ -867,22 +759,6 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
return id;
}
- public async Imap.UID? get_uid_async(ImapDB.EmailIdentifier id, LoadFlags flags,
- Cancellable? cancellable) throws Error {
- // Always look up the UID rather than pull the one from the EmailIdentifier; it could be
- // for another Folder
- Imap.UID? uid = null;
- yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
- LocationIdentifier? location = do_get_location_for_id(cx, id, flags, cancellable);
- if (location != null)
- uid = location.uid;
-
- return Db.TransactionOutcome.DONE;
- }, cancellable);
-
- return uid;
- }
-
public async Gee.Set<Imap.UID>? get_uids_async(Gee.Collection<ImapDB.EmailIdentifier> ids,
LoadFlags flags, Cancellable? cancellable) throws Error {
// Always look up the UID rather than pull the one from the EmailIdentifier; it could be
@@ -902,22 +778,6 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
return (uids.size > 0) ? uids : null;
}
- // Returns null if the UID is not found in this Folder.
- public async ImapDB.EmailIdentifier? get_id_async(Imap.UID uid, LoadFlags flags,
- Cancellable? cancellable) throws Error {
- ImapDB.EmailIdentifier? id = null;
- yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
- LocationIdentifier? location = do_get_location_for_uid(cx, uid, flags,
- cancellable);
- if (location != null)
- id = location.email_id;
-
- return Db.TransactionOutcome.DONE;
- }, cancellable);
-
- return id;
- }
-
public async Gee.Set<ImapDB.EmailIdentifier>? get_ids_async(Gee.Collection<Imap.UID> uids,
LoadFlags flags, Cancellable? cancellable) throws Error {
Gee.Set<ImapDB.EmailIdentifier> ids = new Gee.HashSet<ImapDB.EmailIdentifier>();
@@ -1354,18 +1214,6 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
return (removed_ids.size > 0) ? removed_ids : null;
}
- // Returns the number of messages marked for removal in this folder
- public async int get_marked_for_remove_count_async(Cancellable? cancellable) throws Error {
- int count = 0;
- yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
- count = do_get_marked_removed_count(cx, cancellable);
-
- return Db.TransactionOutcome.DONE;
- }, cancellable);
-
- return count;
- }
-
public async Gee.Set<ImapDB.EmailIdentifier>? get_marked_ids_async(Cancellable? cancellable)
throws Error {
Gee.Set<ImapDB.EmailIdentifier> ids = new Gee.HashSet<ImapDB.EmailIdentifier>();
@@ -1426,52 +1274,6 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
}, cancellable);
}
- public async Gee.Map<ImapDB.EmailIdentifier, Geary.Email.Field>? list_email_fields_by_id_async(
- Gee.Collection<ImapDB.EmailIdentifier> ids, LoadFlags flags, Cancellable? cancellable)
- throws Error {
- if (ids.size == 0)
- return null;
-
- Gee.HashMap<ImapDB.EmailIdentifier,Geary.Email.Field> map = new Gee.HashMap<
- ImapDB.EmailIdentifier,Geary.Email.Field>();
-
- // Break up the work
- Gee.List<ImapDB.EmailIdentifier> list = new Gee.ArrayList<ImapDB.EmailIdentifier>();
- Gee.Iterator<ImapDB.EmailIdentifier> iter = ids.iterator();
- while (iter.next()) {
- list.add(iter.get());
- if (list.size < LIST_EMAIL_FIELDS_CHUNK_COUNT && iter.has_next())
- continue;
-
- yield db.exec_transaction_async(Db.TransactionType.RO, (cx, cancellable) => {
- Gee.List<LocationIdentifier>? locs = do_get_locations_for_ids(cx, ids, flags,
- cancellable);
- if (locs == null || locs.size == 0)
- return Db.TransactionOutcome.DONE;
-
- Db.Statement fetch_stmt = cx.prepare(
- "SELECT fields FROM MessageTable WHERE id = ?");
-
- // TODO: Unroll loop
- foreach (LocationIdentifier location in locs) {
- fetch_stmt.reset(Db.ResetScope.CLEAR_BINDINGS);
- fetch_stmt.bind_rowid(0, location.message_id);
-
- Db.Result results = fetch_stmt.exec(cancellable);
- if (!results.finished)
- map.set(location.email_id, (Geary.Email.Field) results.int_at(0));
- }
-
- return Db.TransactionOutcome.SUCCESS;
- }, cancellable);
-
- list.clear();
- }
- assert(list.size == 0);
-
- return (map.size > 0) ? map : null;
- }
-
public string to_string() {
return path.to_string();
}
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index e32981c41..c68da83a6 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -1120,187 +1120,6 @@ private class Geary.ImapEngine.MinimalFolder : BaseObject,
yield op.wait_for_ready_async(cancellable);
}
- // TODO: A proper public search mechanism; note that this always round-trips to the remote,
- // doesn't go through the replay queue, and doesn't deal with messages marked for deletion
- internal async Geary.Email? find_earliest_email_async(DateTime datetime,
- Geary.EmailIdentifier? before_id, Cancellable? cancellable) throws Error {
- if (before_id != null)
- check_id("find_earliest_email_async", before_id);
-
- Imap.SearchCriteria criteria = new Imap.SearchCriteria();
- criteria.is_(Imap.SearchCriterion.since_internaldate(new
Imap.InternalDate.from_date_time(datetime)));
-
- // if before_id available, only search for messages before it
- if (before_id != null) {
- Imap.UID? before_uid = yield local_folder.get_uid_async(
- (ImapDB.EmailIdentifier) before_id, NONE, cancellable
- );
- if (before_uid == null) {
- throw new EngineError.NOT_FOUND("before_id %s not found in %s", before_id.to_string(),
- to_string());
- }
-
- criteria.and(Imap.SearchCriterion.message_set(
- new Imap.MessageSet.uid_range(new Imap.UID(Imap.UID.MIN), before_uid.previous(true))));
- }
-
- var remote = yield claim_remote_session(cancellable);
- Gee.SortedSet<Imap.UID>? uids = yield remote.search_async(
- criteria, cancellable
- );
- if (uids == null || uids.size == 0) {
- return null;
- }
-
- // if the earliest UID is not in the local store, then need to
- // expand vector to it first
- ImapDB.EmailIdentifier? first_id = yield this.local_folder.get_id_async(
- uids.first(), NONE, cancellable
- );
- if (first_id == null) {
- yield expand_vector_internal(
- remote, uids.first(), 1, OLDEST_TO_NEWEST, cancellable
- );
- first_id = yield this.local_folder.get_id_async(
- uids.first(), NONE, cancellable
- );
- }
-
- return yield this.local_folder.fetch_email_async(
- first_id, PROPERTIES, NONE, cancellable
- );
- }
-
- /**
- * Expands the owning folder's vector.
- *
- * Lists on the remote messages needed to fulfill ImapDB's
- * requirements from `initial_uid` (inclusive) forward to the
- * start of the vector if the OLDEST_TO_NEWEST flag is set, else
- * from `initial_uid` (inclusive) back at most by `count` number
- * of messages. If `initial_uid` is null, the start or end of the
- * vector is used, respectively.
- *
- * The returned UIDs are those added to the vector, which can then
- * be examined and added to the messages to be fulfilled if
- * needed.
- */
- internal async void expand_vector_internal(
- Imap.FolderSession remote,
- Imap.UID? initial_uid,
- int count,
- Folder.ListFlags flags,
- GLib.Cancellable cancellable
- ) throws GLib.Error {
- debug("Expanding vector...");
- int remote_count = remote.folder.properties.email_total;
-
- // include marked for removed in the count in case this is being called while a removal
- // is in process, in which case don't want to expand vector this moment because the
- // vector is in flux
- int local_count = yield this.local_folder.get_email_count_async(
- INCLUDE_MARKED_FOR_REMOVE, cancellable
- );
-
- // watch out for attempts to expand vector when it's expanded as far as it will go
- if (local_count >= remote_count) {
- return;
- }
-
- // Determine low and high position for expansion. The vector
- // start position is based on the assumption that the vector
- // end is the same as the remote end.
- int64 vector_start = (remote_count - local_count + 1);
- int64 low_pos = -1;
- int64 high_pos = -1;
- int64 initial_pos = -1;
-
- if (initial_uid != null) {
- Gee.Map<Imap.UID, Imap.SequenceNumber>? map =
- // this does an IMAP FETCH, but EXPUNGE responses to that
- // are forbidden the returned UIDs are likely fine.
- yield remote.uid_to_position_async(
- new Imap.MessageSet.uid(initial_uid), cancellable
- );
- Imap.SequenceNumber? pos = map.get(initial_uid);
- if (pos != null) {
- initial_pos = pos.value;
- }
- }
-
- // Determine low and high position for expansion
- if (flags.is_oldest_to_newest()) {
- low_pos = Imap.SequenceNumber.MIN;
- if (initial_pos > Imap.SequenceNumber.MIN) {
- low_pos = initial_pos;
- }
- high_pos = vector_start - 1;
- } else {
- // Newest to oldest.
- if (initial_pos <= Imap.SequenceNumber.MIN) {
- high_pos = remote_count;
- low_pos = Numeric.int64_floor(
- high_pos - count + 1, Imap.SequenceNumber.MIN
- );
- } else {
- high_pos = Numeric.int64_floor(
- initial_pos, vector_start - 1
- );
- low_pos = Numeric.int64_floor(
- initial_pos - (count - 1), Imap.SequenceNumber.MIN
- );
- }
- }
-
- if (low_pos > high_pos) {
- debug("Aborting vector expansion, low_pos=%s > high_pos=%s",
- low_pos.to_string(), high_pos.to_string());
- return;
- }
-
- Imap.MessageSet msg_set = new Imap.MessageSet.range_by_first_last(
- new Imap.SequenceNumber(low_pos),
- new Imap.SequenceNumber(high_pos)
- );
- int64 actual_count = (high_pos - low_pos) + 1;
-
- debug("Performing vector expansion using %s for initial_uid=%s count=%d actual_count=%s
local_count=%d remote_count=%d oldest_to_newest=%s",
- msg_set.to_string(),
- (initial_uid != null) ? initial_uid.to_string() : "(null)", count, actual_count.to_string(),
- local_count, remote_count, flags.is_oldest_to_newest().to_string());
-
-
- Gee.List<Geary.Email>? list = yield remote.list_email_async(
- msg_set,
- this._account.local.required_email_fields,
- cancellable
- );
-
- var created_ids = new Gee.HashSet<EmailIdentifier>();
- if (list != null) {
- Gee.Map<Email, bool>? created_or_merged =
- yield local_folder.create_or_merge_email_async(
- list, true, this.harvester, cancellable
- );
-
- foreach (Email email in created_or_merged.keys) {
- if (created_or_merged.get(email)) {
- created_ids.add(email.id);
- }
- }
-
- if (!created_ids.is_empty) {
- if (flags.is_oldest_to_newest()) {
- email_inserted(created_ids);
- } else {
- email_appended(created_ids);
- }
- }
- }
-
- debug("Vector expansion completed (%d new email)", created_ids.size);
- }
-
protected async EmailIdentifier?
create_email_async(RFC822.Message rfc822,
EmailFlags? flags,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]