Commit Graph

201 Commits

Author SHA1 Message Date
Michael Eischer 56ac8360c7 data: split node and snapshot code from restic package 2025-10-03 19:10:39 +02:00
Michael Eischer d8da3d2f2d termstatus: increase test coverage 2025-10-03 18:55:46 +02:00
Michael Eischer f2b9ea6455 termstatus: use errWriter if terminal commands fail 2025-10-03 18:55:46 +02:00
Michael Eischer f045297348 termstatus: fix typo in comment 2025-10-03 18:55:46 +02:00
Michael Eischer 52eb66929f repository: deduplicate index progress bar initializaton 2025-10-03 18:55:46 +02:00
Michael Eischer b459d66288 termstatus: additional comments 2025-10-03 18:55:46 +02:00
Michael Eischer 76b2cdd4fb replace globalOptions.stdout with termstatus.OutputWriter 2025-10-03 18:55:46 +02:00
Michael Eischer c293736841 drop unused stderr from GlobalOptions 2025-10-03 18:55:46 +02:00
Michael Eischer 1939cff334 restore: embed progress.Printer in restore-specific printer 2025-10-03 18:55:46 +02:00
Michael Eischer 1a76f988ea backup: embed progress.Printer in backup specific printer 2025-10-03 18:55:46 +02:00
Michael Eischer e753941ad3 move NewProgressPrinter to ui package 2025-10-03 18:55:46 +02:00
Michael Eischer ff5a0cc851 termstatus: fully wrap reading password from terminal 2025-10-03 18:55:46 +02:00
Michael Eischer 96af35555a termstatus: add stdin and inject into backup command 2025-10-03 18:55:46 +02:00
Michael Eischer 3410808dcf deduplicate termstatus setup 2025-10-03 18:55:46 +02:00
Michael Eischer 1ae2d08d1b termstatus: centralize OutputIsTerminal checks 2025-10-03 18:55:46 +02:00
Michael Eischer c745e4221e termstatus: use errWriter instead of os.Stderr 2025-10-03 18:22:42 +02:00
Michael Eischer 08443fe593 Merge pull request #5405 from restic/dependabot/github_actions/golangci/golangci-lint-action-8
build(deps): bump golangci/golangci-lint-action from 6 to 8
2025-09-21 22:37:26 +02:00
Michael Eischer daeb55a4fb Merge pull request #5511 from greatroar/atomic
ui/progress: Restore atomics in Counter
2025-09-21 22:29:40 +02:00
Michael Eischer 60d80a6127 Fix linter warnings 2025-09-21 22:24:15 +02:00
Michael Eischer 65b21e3348 ui: collect Quote and Truncate helpers
Collect ui formatting helpers in the ui package
2025-09-21 16:44:23 +02:00
Michael Eischer 86ddee8518 ui: document Message / Printer / Terminal interfaces 2025-09-21 16:32:00 +02:00
greatroar a8f506ea4d ui/progress: Simplify Updater
Removed a defer'd call that was a bit subtle.
2025-09-16 09:56:33 +02:00
greatroar 0a1ce4f207 ui/progress: Restore atomics in Counter
We switched from atomics to a mutex in #3189 because of an alignment
bug, but the new-style atomic types don't need manual alignment.
2025-09-16 09:49:48 +02:00
Michael Eischer 94b19d64be termstatus: allow retrieving the underlying writer
This is intended for special cases where it must be guaranteed that the
output on stdout exactly matches what was written to the io.Writer.
2025-09-15 22:17:26 +02:00
Michael Eischer 03600ca509 termstatus: don't buffer stdout
There's not much use in doing so as nearly every write call was paired
with a flush call. Thus, just use an unbuffered writer.
2025-09-15 21:22:07 +02:00
Michael Eischer 91ecac8003 termstatus: fix crash when printing empty string 2025-09-15 20:25:17 +02:00
Michael Eischer 32b7168a9e centralize index progress bar for termstatus 2025-09-15 20:25:17 +02:00
Michael Eischer 43b5166de8 terminal: cleanup determining width 2025-09-08 11:03:42 +02:00
Michael Eischer 93ccc548c8 termstatus: move cursor handling to terminal package 2025-09-08 11:03:17 +02:00
Michael Eischer 0ab38faa2e termstatus: track current status also in background
Without this, restic could temporarily print an outdated status when
moving back into the foreground.
2025-09-08 10:50:53 +02:00
Michael Eischer 48cbbf9651 ui/termstatus: extract background handling code 2025-09-08 10:50:09 +02:00
greatroar 1ed93bd54d backend,termstatus: Unify foreground/background detection
PR #5358 reintroduced a version of the TIOCGPGRP ioctl call that works
on all Unix platforms except Linux, due to a bug/inconsistency in
x/sys/unix. This commit fixes that by introducing termstatus.Tcgetpgrp.

It also introduces termstatus.Getpgrp and termstatus.Tcsetpgrp to deal
with the different signature of unix.Getpgrp in Solaris vs. all other
Unix platforms and an int-overflowing constant on AIX, so that some
AIX/Solaris-specific code can be removed elsewhere and
foreground/background detection is done the same everywhere except on
Windows.
2025-09-08 09:33:44 +02:00
Michael Eischer 66a8e897a9 Merge pull request #5300 from MichaelEischer/fix-output-race
ui/termstatus: fix race condition in StdioWrapper
2025-03-24 11:17:14 +01:00
Michael Eischer ec19d67512 ui/termstatus: fix race condition in StdioWrapper 2025-03-24 11:07:15 +01:00
Michael Eischer f7f48b3026 ui/progress: extend Printer interface with print to stdout method 2025-03-23 17:46:04 +01:00
Martin Smith f238f81ba6 Renames to fix clashes with reserved words. 2025-03-22 18:20:30 +00:00
Martin Smith 3788605127 Rename unused parameters to '_'. 2025-03-22 18:20:30 +00:00
Martin Smith 092899df8b Remove unnecessary type conversions. 2025-03-22 18:20:30 +00:00
Martin Smith 1daf5317f8 Fix import ordering. 2025-03-22 18:20:30 +00:00
greatroar c1781e0abb ui/termstatus: Remove unused bytes.Buffer 2025-02-01 08:21:40 +01:00
Srigovind Nayak d7d9af4c9f ui: restore --delete indicates number of deleted files (#5100)
* ui: restore --delete indicates number of deleted files

* adds new field `FilesDeleted` to the State struct, JSON and text progress updaters
* increment FilesDeleted count when ReportedDeletedFile

* ui: collect the files to be deleted, delete, then update the count post deletion

* docs: update scripting output fields for restore command

ui: report deleted directories and refactor function name to ReportDeletion
2024-12-01 15:29:11 +01:00
Michael Eischer 9c758313e3 Merge pull request #5119 from MichaelEischer/backup-json-start-end-time
backup: include start and end time in json output
2024-11-11 21:50:30 +01:00
Michael Eischer 569a117a1d improve fprintf related error handling 2024-11-01 17:07:43 +01:00
Michael Eischer e65f4e2231 backup: include start and end time in json output
The timestamps were already stored in the created snapshot.
2024-11-01 16:31:34 +01:00
Michael Eischer ca1e5e10b6 add proper constants for node type 2024-08-31 18:20:01 +02:00
Michael Terry 88f59fc2d6 json: switch backup and restore errors from string to struct types
This keeps backwards compatibility with the previous empty structs.
And maybe we'd want to put other fields into the inner struct later,
rather than the outer message.
2024-08-03 16:21:44 -04:00
Michael Terry a376323331 restore: print JSON versions of errors in --json mode
Previously, they were printed as freeform text.

This also adds a ui.Terminal interface to make writing
tests easier and also adds a few tests.
2024-08-03 15:18:46 -04:00
Michael Terry ad2585af67 backup: show actual error strings in --json mode
Previously, an error JSON fragment would look like:
{"message_type": "error", "error": {}}

This is because encoding/json cannot marshal an error interface.
Instead, we now call .Error() to get the string value.
2024-08-03 15:07:52 -04:00
Michael Terry f4bdfea1c9 backup: print scanner errors to stderr, not stdout 2024-08-03 15:07:52 -04:00
Michael Eischer 59c880fce3 restorer: only show size in text output for files 2024-07-20 12:46:28 +02:00