From 833bbdbb11221f95bdb2266de25276b75b539236 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 5 Feb 2019 01:45:16 +0300 Subject: [PATCH] Improve merge_choose_remote_location. GitOrigin-RevId: 0c145a4a1f6d43ebdf5eb618b581539f31eabc40 --- td/telegram/files/FileManager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index a9eb80f5d..89ec35569 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -1014,11 +1014,19 @@ static int merge_choose_remote_location(const FullRemoteFileLocation &x, int8 x_ return !x_ref; } if (x.get_raw_file_reference() != y.get_raw_file_reference()) { - return x_source < y_source; + if (x_source != y_source) { + return x_source < y_source; + } + // prefer newest among two server locations + return 0; } } if (x.get_access_hash() != y.get_access_hash()) { - return x_source < y_source; + if (x_source != y_source) { + return x_source < y_source; + } + // prefer newest among two server locations + return 0; } return 2; }