Skip to content

Commit 000c7e1

Browse files
committed
feat: refresh data files improvement
1 parent f059fa9 commit 000c7e1

6 files changed

Lines changed: 547 additions & 87 deletions

File tree

TelegramDownloader/Data/FileService.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ private string GetMimeType(string fileName)
16391639
return contentType;
16401640
}
16411641

1642-
public async Task refreshChannelFIles(string channelId, bool force = false)
1642+
public async Task refreshChannelFIles(string channelId, bool force = false, RefreshChannelOptions? refreshOptions = null)
16431643
{
16441644
int totalNewMessages = 0;
16451645
refreshMutex.WaitOne();
@@ -1648,7 +1648,11 @@ public async Task refreshChannelFIles(string channelId, bool force = false)
16481648
DateTime init = DateTime.Now;
16491649
List<int> presentIds = await _db.getAllIdsFromChannel(channelId);
16501650
_logger.LogInformation($"Refresh channel with id: {channelId}");
1651-
List<TelegramChatDocuments> telegramChatDocuments = (await _ts.searchAllChannelFiles(Convert.ToInt64(channelId), (presentIds.Count > 0 && !force) ? presentIds.Max() : 0)).Where(x => x.name != null).ToList();
1651+
1652+
// Use default options if none provided
1653+
refreshOptions ??= new RefreshChannelOptions();
1654+
1655+
List<TelegramChatDocuments> telegramChatDocuments = (await _ts.searchAllChannelFiles(Convert.ToInt64(channelId), (presentIds.Count > 0 && !force) ? presentIds.Max() : 0, refreshOptions)).Where(x => x.name != null).ToList();
16521656
_logger.LogInformation($"Get the telegram files in: {(DateTime.Now - init).TotalSeconds} seconds for channel id:{channelId}");
16531657
List<string> fileNames = await _db.getAllFileNamesFromChannel(channelId);
16541658
var nameCount = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

TelegramDownloader/Data/IFileService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface IFileService
4141
Task UploadFile(string dbName, string currentPath, UploadFiles file);
4242
Task UploadFileFromServer(string dbName, string currentPath, List<FileManagerDirectoryContent> files, InfoDownloadTaksModel dm = null);
4343
Task AddUploadFileFromServer(string dbName, string currentPath, List<FileManagerDirectoryContent> files, InfoDownloadTaksModel idt = null);
44-
Task refreshChannelFIles(string channelId, bool force = false);
44+
Task refreshChannelFIles(string channelId, bool force = false, RefreshChannelOptions? refreshOptions = null);
4545
bool isChannelRefreshing(string channelId);
4646
Task<int> PreloadFilesToTemp(string channelId, List<FileManagerDirectoryContent> items);
4747
Task DownloadPlaylistToLocal(PlaylistModel playlist, string destinationFolder);

TelegramDownloader/Data/ITelegramService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface ITelegramService
4141
Task logOff();
4242
Task sendVerificationCode(string vc);
4343
Task<Message> uploadFile(string chatId, Stream file, string fileName, string mimeType = null, UploadModel um = null, string caption = null);
44-
Task<List<TelegramChatDocuments>> searchAllChannelFiles(long id, int lastId);
44+
Task<List<TelegramChatDocuments>> searchAllChannelFiles(long id, int lastId, Models.RefreshChannelOptions? options = null);
4545
bool isMyChat(long id);
4646
bool isChannelOwner(long id);
4747
Task<TL.Channel?> CreateChannel(string title, string about);

0 commit comments

Comments
 (0)