From 331c8b52c15197a709fa16cd4736018ce995dc11 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Thu, 1 Aug 2019 16:03:11 +0300 Subject: [PATCH] FileLoader: add comment about FILE_UPLOAD_RESTART GitOrigin-RevId: e8fb51da493cacd00af5ec7585cd8a95b605838a --- td/telegram/files/FileLoader.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/td/telegram/files/FileLoader.cpp b/td/telegram/files/FileLoader.cpp index a2b4af24..6df62d64 100644 --- a/td/telegram/files/FileLoader.cpp +++ b/td/telegram/files/FileLoader.cpp @@ -98,6 +98,18 @@ void FileLoader::start_up() { auto &ready_parts = file_info.ready_parts; auto use_part_count_limit = file_info.use_part_count_limit; bool is_upload = file_info.is_upload; + + // Two cases when FILE_UPLOAD_RESTART will happen + // 1. File is ready, size is final. But there are more uploaded parts, than size of a file + //pm.init(1, 100000, true, 10, {0, 1, 2}, false, true).ensure_error(); + // This error is definitely ok, because we are using actual size of file on disk (mtime is checked by somebody + // else). And actual size could change arbitrarily. + // + // 2. size is unknown/zero, size is not final, some parts of file are already uploaded + // pm.init(0, 100000, false, 10, {0, 1, 2}, false, true).ensure_error(); + // This case is more complicated + // It means that at some point we got inconsistent state. Like deleted local location, but left partial remote + // locaiton untouched. This is completely possible at this point, but probably should be fixed. auto status = parts_manager_.init(size, expected_size, is_size_final, part_size, ready_parts, use_part_count_limit, is_upload); if (status.is_error()) {