-
Notifications
You must be signed in to change notification settings - Fork 1
feat(downloader): report release download progress via listener #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5846d20
feat(downloader): report release download progress via listener
claude f1e6f12
fix(downloader): close body stream safely and bound body read time
claude 3003afd
test(downloader): use hasSizeGreaterThan for progress assertion
claude cd6a894
perf(downloader): use a 256 KiB copy buffer for large archives
claude 7df66fd
refactor(downloader): give the body stream a single owner
claude e9e955c
refactor(downloader): close the response stream in its owning method
claude e570f7d
refactor(downloader): inject release catalog and http client for test…
claude 0b9064d
test(downloader): mock HttpClient and drop the legacy constructors
claude 50cb1d9
refactor(downloader): drop ReleaseCatalog and keep one injected-clien…
claude 87d7d59
refactor(downloader): inject a mockable GitHubReleaseClient instead o…
claude 540f48f
test(downloader): tidy AtomicInteger import and fresh mock body per send
claude 290e284
Merge remote-tracking branch 'origin/master' into claude/github-issue…
claude 3651a4e
refactor(downloader): let github-api own its HTTP client for release …
claude 47edf7c
perf(downloader): stop at the first non-draft release without paging all
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/github/_1c_syntax/utils/downloader/DownloadProgressListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * This file is a part of 1c-syntax utils. | ||
| * | ||
| * Copyright (c) 2018-2026 | ||
| * Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors | ||
| * | ||
| * SPDX-License-Identifier: LGPL-3.0-or-later | ||
| * | ||
| * 1c-syntax utils is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 3.0 of the License, or (at your option) any later version. | ||
| * | ||
| * 1c-syntax utils is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with 1c-syntax utils. | ||
| */ | ||
| package com.github._1c_syntax.utils.downloader; | ||
|
|
||
| /** | ||
| * Слушатель прогресса скачивания ассета релиза. | ||
| * | ||
| * <p>Вызывается загрузчиком по мере вычитывания тела ответа: сначала один раз с нулём вычитанных | ||
| * байт, затем после каждого прочитанного блока. Позволяет клиенту (например, IntelliJ-плагину) | ||
| * рисовать прогресс-бар вместо неопределённого «крутящегося» индикатора. | ||
| * | ||
| * <p>Реализация может бросить {@link RuntimeException} (в частности, для отмены операции) — | ||
| * исключение пробрасывается наружу через вызов загрузки, а частично скачанный файл удаляется. | ||
| */ | ||
| @FunctionalInterface | ||
| public interface DownloadProgressListener { | ||
|
|
||
| /** | ||
| * Слушатель, ничего не делающий — значение по умолчанию, когда прогресс не нужен. | ||
| */ | ||
| DownloadProgressListener NONE = (bytesRead, totalBytes) -> { | ||
| // no-op | ||
| }; | ||
|
|
||
| /** | ||
| * @param bytesRead сколько байт ассета уже скачано | ||
| * @param totalBytes полный размер ассета в байтах или {@code -1}, если сервер его не сообщил | ||
| */ | ||
| void onProgress(long bytesRead, long totalBytes); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.