Giter Club home page Giter Club logo

borg-ncdu-analyzer's Issues

Crashes on files in /

I used borg-ncdu-analyzer succesfully before, but it crashes on my most recent backup (the JSON output lines are debug output from a print(line) I inserted into the code):

martin borg # python3 /home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py  ./::archive
Dumping and processing archive...
b'{"type": "d", "mode": "drwxr-xr-x", "user": "root", "group": "root", "uid": 0, "gid": 0, "path": ".", "healthy": true, "source": "", "linktarget": "", "flags": null, "mtime": "2020-05-24T18:56:04.382781", "size": 0}\n'
b'{"type": "d", "mode": "drwx------", "user": "root", "group": "root", "uid": 0, "gid": 0, "path": "lost+found", "healthy": true, "source": "", "linktarget": "", "flags": null, "mtime": "2011-10-24T23:20:06.000000", "size": 0}\n'
b'{"type": "-", "mode": "-rw-------", "user": "root", "group": "root", "uid": 0, "gid": 0, "path": ".bash_history", "healthy": true, "source": "", "linktarget": "", "flags": null, "mtime": "2015-10-11T17:48:52.276437", "size": 52}\n'
Received SIGTERM
Traceback (most recent call last):
  File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 179, in <module>
    main()
  File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 143, in main
    analyzer.process_lines(read_lines_from_process(p))
  File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 94, in process_lines
    self._fs_cache[parent_dir].add_entry(entry)
KeyError: ''

I believe it crashes on files that were in / when the backup ran, in this case .bash_history. The parent_dir of these files is "", but as that has never been added as a directory, the code crashes here.

Won't run on Ubuntu 18.04 because Python 3.6 doesn't have dataclasses

I tried this on Ubuntu 18.04, but it won't run:

martin borg # python3 /home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py  ./::archive
Traceback (most recent call last):
  File "/home/martin/borg-ncdu-analyzer/borg_ncdu_analyzer.py", line 6, in <module>
    from dataclasses import dataclass
ModuleNotFoundError: No module named 'dataclasses'

To get it working, I haphazardly removed the dependency:

martin@martin ~/borg-ncdu-analyzer % git diff
diff --git a/borg_ncdu_analyzer.py b/borg_ncdu_analyzer.py
old mode 100644
new mode 100755
index 034264b..2d9b049
--- a/borg_ncdu_analyzer.py
+++ b/borg_ncdu_analyzer.py
@@ -1,18 +1,22 @@
+#!/usr/bin/python3
 import os
 import signal
 import subprocess
 import json
 import tempfile
-from dataclasses import dataclass
 from typing import List, Dict, Iterator, Tuple, Iterable
 
 
-@dataclass
 class FSEntry:
     name: str
     size: int
     sub: List['FSEntry']
 
+    def __init__(self, name: str, size: int, sub: List['FSEntry']):
+        self.name = name
+        self.size = size
+        self.sub = sub
+
     def add_entry(self, entry: 'FSEntry'):
         self.sub.append(entry)
 

Seems to work ¯\(ツ)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.