Skip to content
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

use --json-lines mode for list archive results for better parsing of unusual filenames #885

Merged
merged 2 commits into from
Mar 1, 2021

Conversation

rblenis
Copy link
Contributor

@rblenis rblenis commented Feb 22, 2021

This change relies on using borg >= 1.1.0. Do we need to support older versions? If so, I can add checks for borg version and fallback to old text parsing. This fixes one of the 2 cases in issue #883.

@rblenis rblenis force-pushed the issue_883 branch 3 times, most recently from 8fdcc0d to d9ca64c Compare February 22, 2021 08:04
@m3nu
Copy link
Contributor

m3nu commented Feb 22, 2021

Neat 👍

Actually we already have a way to use different borg features, depending on version. Base class is here: https://github.com/borgbase/vorta/blob/master/src/vorta/borg/_compatibility.py

See it in action: https://github.com/borgbase/vorta/blob/master/src/vorta/borg/create.py#L115

@rblenis
Copy link
Contributor Author

rblenis commented Feb 22, 2021

ok, awesome. I also saw in BorgThread that at least borg 1.1.0 is required to do anything, so I don't need to support the non "--json-lines" archive list output. I also just fixed issue of datetime for python < 3.7

@codecov-io
Copy link

codecov-io commented Feb 23, 2021

Codecov Report

Merging #885 (47e8b7c) into master (84c3d3c) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #885      +/-   ##
==========================================
- Coverage   70.32%   70.28%   -0.04%     
==========================================
  Files          56       56              
  Lines        3791     3793       +2     
==========================================
  Hits         2666     2666              
- Misses       1125     1127       +2     
Impacted Files Coverage Δ
src/vorta/borg/list_archive.py 66.66% <100.00%> (-3.34%) ⬇️
src/vorta/views/archive_tab.py 77.28% <100.00%> (-0.11%) ⬇️
src/vorta/views/extract_dialog.py 93.65% <100.00%> (-2.85%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84c3d3c...47e8b7c. Read the comment docs.

@rblenis rblenis force-pushed the issue_883 branch 2 times, most recently from 38cb192 to 47e8b7c Compare February 26, 2021 03:57
@rblenis
Copy link
Contributor Author

rblenis commented Feb 27, 2021

Updated/split issue #883 into 2 issues, so now this PR completely fixes issue #883, instead of fixing only one of the bugs in (old) issue #883.

@m3nu
Copy link
Contributor

m3nu commented Feb 27, 2021

I'll do some edits, as usual. E.g. would like to add this to the compatibility class, since it needs a newer Borg.

@rblenis
Copy link
Contributor Author

rblenis commented Feb 28, 2021

Does this ('list --json-lines') need compatibility check? It seems that the bare minimum borg version for vorta (because of --json-logs' support, which is cheecked in base borg_thread) is borg 1.1.0, which also supports 'list --json-lines'.

@m3nu
Copy link
Contributor

m3nu commented Feb 28, 2021

You're right. We require >1.1.0 already

ret['message'] = trans_late('messages', 'Your Borg version is too old. >=1.1.0 is required.')

@m3nu m3nu removed the status:ready label Mar 1, 2021
src/vorta/borg/list_archive.py Show resolved Hide resolved
# modified = datetime.fromisoformat(data["mtime"]).ctime()
# python < 3.7
try:
modified = datetime.strptime(data["mtime"], "%Y-%m-%dT%H:%M:%S.%f").ctime()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using the date string as-is? Else this could get slow for many entries. (hundreds of thousands of files are common) Back when I added the feature, I tried hard to keep it fast.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it's still fast even when parsing the date. Tried with 40k files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall now, but I think I was trying to get it into a datetime object so it would be easier to manipulate how it was displayed on the gui, if ever needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The time string from json is a bit ugly with MS included. So let's just use ctime() for now. Maybe in the future there could be a setting for a default time format or something.

@m3nu m3nu merged commit c66b102 into borgbase:master Mar 1, 2021
@rblenis rblenis deleted the issue_883 branch March 1, 2021 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants