Skip to content

Commit

Permalink
Improve get debug data (#413)
Browse files Browse the repository at this point in the history
* Improve get debug data

* adapt the fakefs reader
  • Loading branch information
simulot authored Jul 30, 2024
1 parent 356bf1b commit ca96b75
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
10 changes: 6 additions & 4 deletions browser/gp/testgp_samples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ func loadFromString(dateFormat string, s string) []fs.FS {
}

func checkLivePhotoPixil() []fs.FS {
return loadFromString("01-02-2006 15:04", `Archive: takeout-20230720T065335Z-001.zip
return loadFromString("01-02-2006 15:04", `Part: takeout-20230720T065335Z-001.zip
Archive: takeout-20230720T065335Z-001.zip
Length Date Time Name
--------- ---------- ----- ----
309 03-05-2023 10:10 Takeout/Google Photos/2022 - Germany/metadata.json
Expand All @@ -299,7 +300,8 @@ func checkLivePhotoPixil() []fs.FS {
}

func checkMissingJSON() []fs.FS {
return loadFromString("01-02-2006 15:04", `Archive: takeout-20230720T065335Z-001.zip
return loadFromString("01-02-2006 15:04", `Part: takeout-20230720T065335Z-001.zip
Archive: takeout-20230720T065335Z-001.zip
Length Date Time Name
--------- ---------- ----- ----
803 07-19-2023 23:58 Takeout/Google Photos/Photos from 2022/IMG_4573.HEIC.json
Expand All @@ -313,14 +315,14 @@ func checkMissingJSON() []fs.FS {
}

func checkDuplicates() []fs.FS {
return loadFromString("01-02-2006 15:04", `Archive: takeout-20230720T065335Z-001.zip
return loadFromString("01-02-2006 15:04", `Part: takeout-20230720T065335Z-001.tgz
-rw-r--r-- 0/0 365022 2024-07-19 01:19 Takeout/Google Foto/[E&S] 2016-01-05 - Castello De Albertis e Mostra d/20160105_121621_LLS.jpg
-rw-r--r-- 0/0 708 2024-07-19 01:19 Takeout/Google Foto/[E&S] 2016-01-05 - Castello De Albertis e Mostra d/20160105_121621_LLS.jpg.json
-rw-r--r-- 0/0 364041 2024-07-19 01:51 Takeout/Google Foto/Photos from 2016/20160105_121621_LLS.jpg
-rw-r--r-- 0/0 709 2024-07-19 01:51 Takeout/Google Foto/Photos from 2016/20160105_121621_LLS.jpg.json
-rw-r--r-- 0/0 708 2024-07-19 02:13 Takeout/Google Foto/2016-01-05 - _3/20160105_121621_LLS.jpg.json
-rw-r--r-- 0/0 364041 2024-07-19 02:20 Takeout/Google Foto/2016-01-05 - _3/20160105_121621_LLS.jpg
Archive: takeout-20230720T065335Z-002.zip
Part: takeout-20230720T065335Z-002.tgz
-rw-r--r-- 0/0 364041 2024-07-19 06:14 Takeout/Google Foto/2016-01-05 - _3/20160105_121621_LLS.jpg
-rw-r--r-- 0/0 708 2024-07-19 02:13 Takeout/Google Foto/2016-01-05 - _3/20160105_121621_LLS.jpg.json
`)
Expand Down
8 changes: 4 additions & 4 deletions docs/how-to-send-debug-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ If you agree, you can share it with me via a DM on discord @simulot.
## Get the file list from a zip takeout

```sh
for f in *.zip; do echo "$f:"; unzip -l $f; done >list.lst
for f in *.zip; do echo "Part: $f"; unzip -l $f; done >list.lst
```

This produces a file like this:
```
takeout-20240523T170453Z-001.zip:
Part: takeout-20240523T170453Z-001.zip:
Archive: takeout-20240523T170453Z-001.zip
Length Date Time Name
--------- ---------- ----- ----
Expand Down Expand Up @@ -55,12 +55,12 @@ Archive: takeout-20240523T170453Z-001.zip
## Get the file list from a tgz takeout

```sh
for f in *.tgz; do echo "$f:"; tar -tzvf $f; done >list.lst
for f in *.tgz; do echo "Part: $f"; tar -tzvf $f; done >list.lst
```

This produces a file like this:
```
takeout-20231209T153001Z-001.tgz:
Part: takeout-20231209T153001Z-001.tgz:
-rw-r--r-- 0/0 3987330 2023-12-09 16:30 Takeout/Google Photos/Photos from 2023/PXL_20231207_192201288.PORTRAIT.jpg
-rw-r--r-- 0/0 3825143 2023-12-09 16:30 Takeout/Google Photos/Photos from 2023/PXL_20231207_192200378.PORTRAIT.jpg
-rw-r--r-- 0/0 838 2023-12-09 16:30 Takeout/Google Photos/Photos from 2023/PXL_20231207_202525504.jpg.json
Expand Down
13 changes: 13 additions & 0 deletions internal/fakefs/ziplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ func ScanFileListReader(f io.Reader, dateFormat string) ([]fs.FS, error) {
scanner := bufio.NewScanner(f)
for scanner.Scan() {
l := scanner.Text()
if strings.HasPrefix(l, "Part:") {
currentZip = strings.TrimSpace(strings.TrimPrefix(l, "Part:"))
fsys, ok = fsyss[currentZip]
if !ok {
fsys = &FakeFS{
name: currentZip,
files: map[string]map[string]FakeDirEntry{},
}

fsyss[currentZip] = fsys
}
continue
}
if strings.HasPrefix(l, "Archive:") {
currentZip = strings.TrimSpace(strings.TrimPrefix(l, "Archive:"))
fsys, ok = fsyss[currentZip]
Expand Down

0 comments on commit ca96b75

Please sign in to comment.