Skip to content

Conversation

@abakum
Copy link
Contributor

@abakum abakum commented Nov 17, 2025

… unzip. Tests. Fix RemoveMarkedFiles.

@abakum
Copy link
Contributor Author

abakum commented Nov 18, 2025

koka@koka:~/src/croc/src/utils$ go test -v
go: downloading golang.org/x/term v0.36.0
=== RUN TestExists
[10.255.255.254 172.22.218.56]
--- PASS: TestExists (0.08s)
=== RUN TestMD5HashFile
--- PASS: TestMD5HashFile (0.25s)
=== RUN TestHighwayHashFile
--- PASS: TestHighwayHashFile (0.06s)
=== RUN TestIMOHashFile
--- PASS: TestIMOHashFile (0.06s)
=== RUN TestXXHashFile
--- PASS: TestXXHashFile (0.08s)
=== RUN TestSHA256
--- PASS: TestSHA256 (0.00s)
=== RUN TestByteCountDecimal
--- PASS: TestByteCountDecimal (0.00s)
=== RUN TestMissingChunks
--- PASS: TestMissingChunks (0.00s)
=== RUN TestHashFile
--- PASS: TestHashFile (0.00s)
=== RUN TestPublicIP
109.165.8.176
--- PASS: TestPublicIP (0.19s)
=== RUN TestLocalIP
172.22.218.56
--- PASS: TestLocalIP (0.00s)
=== RUN TestGetRandomName
2618-puma-opera-system
--- PASS: TestGetRandomName (0.00s)
=== RUN TestFindOpenPorts
--- PASS: TestFindOpenPorts (0.00s)
=== RUN TestIsLocalIP
--- PASS: TestIsLocalIP (0.00s)
=== RUN TestValidFileName
--- PASS: TestValidFileName (0.00s)
=== RUN TestZipDirectory
Zipping /tmp/zip_test3419969786 to /tmp/zip_test3419969786/test.zip
Adding test/test.zip
--- PASS: TestZipDirectory (0.00s)
=== RUN TestUnzipDirectory
Unzipping file /tmp/unzip_test1708701110/extracted/test/file3.txt
--- PASS: TestUnzipDirectory (0.00s)
=== RUN TestUnzipWithExistingFiles
utils_test.go:413: Skipping overwrite test as it requires GetInput mocking
--- PASS: TestUnzipWithExistingFiles (0.00s)
=== RUN TestZipNonExistentDirectory
[error] 2025/11/18 21:03:56 utils.go:483: Source directory does not exist: /tmp/zip_nonexistent_test4223958186/nonexistent
utils_test.go:439: Function returned error (expected): source directory does not exist: /tmp/zip_nonexistent_test4223958186/nonexistent
--- PASS: TestZipNonExistentDirectory (0.00s)
=== RUN TestUnzipInvalidFile
[error] 2025/11/18 21:03:56 utils.go:569: zip: not a valid zip file
utils_test.go:467: Function returned error (expected): failed to open zip file: zip: not a valid zip file
--- PASS: TestUnzipInvalidFile (0.00s)
=== RUN TestUnzipWithCorruptedZip
Unzipping file /tmp/unzip_corrupted_test884077555/corrupted/file3.txt
utils_test.go:511: Function completed without error on corrupted zip
--- PASS: TestUnzipWithCorruptedZip (0.00s)
=== RUN TestUnzipContinuesOnErrors
Unzipping file /tmp/unzip_continue_test666911900/problematic/another_good_file.txt
--- PASS: TestUnzipContinuesOnErrors (0.00s)
=== RUN TestZipAndUnzipRoundTrip
Zipping /tmp/roundtrip_test2669098521/source to /tmp/roundtrip_test2669098521/test.zip
Adding test/subdir2/file3.txt
Unzipping file /tmp/roundtrip_test2669098521/extracted/test/subdir2/file3.txt
--- PASS: TestZipAndUnzipRoundTrip (0.00s)
=== RUN TestZipEmptyDirectory
Zipping /tmp/zip_empty_test520659923/empty to /tmp/zip_empty_test520659923/empty.zip

--- PASS: TestZipEmptyDirectory (0.00s)
=== RUN TestUnzipToNonExistentDirectory
Unzipping file /tmp/unzip_nonexistent_dest_test1266215739/nonexistent/deep/path/test/file3.txt
--- PASS: TestUnzipToNonExistentDirectory (0.00s)
PASS
ok github.com/schollz/croc/v10/src/utils 0.731s
koka@koka:~/src/croc/src/utils$

@schollz
Copy link
Owner

schollz commented Nov 18, 2025

It doesn't seem to work?

Sender:

$ ./croc send --zip src                                                                                                                             
$ ls -l --full-time src                                                                                                                            
total 48
drwxrwxr-x 2 zns zns 4096 2025-10-16 07:44:43.729485898 -0700 cli
drwxrwxr-x 2 zns zns 4096 2025-09-30 06:45:58.798080717 -0700 comm
drwxrwxr-x 2 zns zns 4096 2025-09-30 06:45:58.798080717 -0700 compress
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:12:04.520015350 -0800 croc
drwxrwxr-x 2 zns zns 4096 2025-09-30 06:45:58.798080717 -0700 crypt
drwxrwxr-x 2 zns zns 4096 2025-09-30 06:45:58.798080717 -0700 diskusage
drwxrwxr-x 2 zns zns 4096 2025-10-16 07:44:43.729485898 -0700 install
drwxrwxr-x 2 zns zns 4096 2025-09-30 06:45:58.800080741 -0700 message
drwxrwxr-x 2 zns zns 4096 2025-09-30 06:45:58.800080741 -0700 mnemonicode
drwxrwxr-x 2 zns zns 4096 2025-09-30 06:45:58.800080741 -0700 models
drwxrwxr-x 3 zns zns 4096 2025-09-30 07:13:54.592567644 -0700 tcp
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:11:59.274943137 -0800 utils

Receiver:

$ ../croc --yes zackary                                                                                                                         Receiving 'src.zip' (894.2 kB) 
$ ls -l --full-time src                                                                                                                         
total 48
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 cli
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 comm
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 compress
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 croc
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 crypt
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 diskusage
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 install
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 message
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 mnemonicode
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.588749583 -0800 models
drwxrwxr-x 3 zns zns 4096 2025-11-18 11:14:11.589749596 -0800 tcp
drwxrwxr-x 2 zns zns 4096 2025-11-18 11:14:11.589749596 -0800 utils

I was expecting the receiver to have modified times

@abakum
Copy link
Contributor Author

abakum commented Nov 19, 2025

Yes, this version save times of files to zip and restore times of files but not dirs on unzip
----------------------------------send
1koka@debian:~/src/croc/src/utils$ ls -laR --full-time /tmp/roundtrip_test1909451369/source
/tmp/roundtrip_test1909451369/source:
итого 24
drwxr-xr-x 4 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 .
drwx------ 4 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 ..
-rw-r--r-- 1 koka koka 17 2023-03-01 17:30:00.000000000 +0300 file1.txt
-rw-r--r-- 1 koka koka 17 2023-03-01 17:33:00.000000000 +0300 file4.txt
drwxr-xr-x 2 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 subdir
drwxr-xr-x 2 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 subdir2

/tmp/roundtrip_test1909451369/source/subdir:
итого 12
drwxr-xr-x 2 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 .
drwxr-xr-x 4 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 ..
-rw-r--r-- 1 koka koka 27 2023-03-01 17:31:00.000000000 +0300 file2.txt

/tmp/roundtrip_test1909451369/source/subdir2:
итого 12
drwxr-xr-x 2 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 .
drwxr-xr-x 4 koka koka 4096 2025-11-19 08:45:39.929997794 +0300 ..
-rw-r--r-- 1 koka koka 35 2023-03-01 17:32:00.000000000 +0300 file3.txt

1koka@debian:~/src/croc/src$ croc send --zip /tmp/roundtrip_test1909451369/source
Zipping /tmp/roundtrip_test1909451369/source to source.zip
Adding source/subdir2/file3.txt
Sending 'source.zip' (756 B)
Code is: *

On the other computer run:
(For Windows)
croc --relay * --pass * *
(For Linux/macOS)
CROC_SECRET=* croc * --pass *

Sending (->192.168.0.12:54218)
source.zip 100% |████████████████████| (756/756 B, 982 kB/s)
Removing source.zip

----------------------------------recv
1koka@debian:~/src/croc/src/utils$ CROC_SECRET=* croc --relay * --pass * --yes
Receiving 'source.zip' (756 B)

Receiving (<-127.0.0.1:56662)
source.zip 100% |████████████████████| (756/756 B, 90 kB/s)
Unzipping file source/subdir2/file3.txt
1koka@debian:~/src/croc/src/utils$ ls -laR --full-time source
source:
итого 24
drwxr-xr-x 4 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 .
drwxr-xr-x 3 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 ..
-rw-r--r-- 1 koka koka 17 2023-03-01 17:30:00.000000000 +0300 file1.txt
-rw-r--r-- 1 koka koka 17 2023-03-01 17:33:00.000000000 +0300 file4.txt
drwxr-xr-x 2 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 subdir
drwxr-xr-x 2 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 subdir2

source/subdir:
итого 12
drwxr-xr-x 2 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 .
drwxr-xr-x 4 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 ..
-rw-r--r-- 1 koka koka 27 2023-03-01 17:31:00.000000000 +0300 file2.txt

source/subdir2:
итого 12
drwxr-xr-x 2 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 .
drwxr-xr-x 4 koka koka 4096 2025-11-19 09:06:45.871783290 +0300 ..
-rw-r--r-- 1 koka koka 35 2023-03-01 17:32:00.000000000 +0300 file3.txt

Next I fix restore times of dirs

@abakum
Copy link
Contributor Author

abakum commented Nov 19, 2025

---send
1koka@debian:~/src/croc$ ls -laR --full-time /tmp/roundtrip_test/source
/tmp/roundtrip_test/source:
итого 24
drwxr-xr-x 4 koka koka 4096 2023-03-01 17:30:00.000000000 +0300 .
drwx------ 4 koka koka 4096 2025-11-19 15:09:04.863629444 +0300 ..
-rw-r--r-- 1 koka koka 17 2023-03-01 17:31:00.000000000 +0300 file1.txt
-rw-r--r-- 1 koka koka 17 2023-03-01 17:31:00.000000000 +0300 file4.txt
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:29:00.000000000 +0300 subdir
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:28:00.000000000 +0300 subdir2

/tmp/roundtrip_test/source/subdir:
итого 12
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:29:00.000000000 +0300 .
drwxr-xr-x 4 koka koka 4096 2023-03-01 17:30:00.000000000 +0300 ..
-rw-r--r-- 1 koka koka 27 2023-03-01 17:31:00.000000000 +0300 file2.txt

/tmp/roundtrip_test/source/subdir2:
итого 12
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:28:00.000000000 +0300 .
drwxr-xr-x 4 koka koka 4096 2023-03-01 17:30:00.000000000 +0300 ..
-rw-r--r-- 1 koka koka 35 2023-03-01 17:31:00.000000000 +0300 file3.txt

---recv
1koka@debian:~/src/croc/src/utils$ ls -laR --full-time source
source:
итого 24
drwxr-xr-x 4 koka koka 4096 2023-03-01 17:30:00.000000000 +0300 .
drwxr-xr-x 3 koka koka 4096 2025-11-19 15:12:09.744317071 +0300 ..
-rw-r--r-- 1 koka koka 17 2023-03-01 17:31:00.000000000 +0300 file1.txt
-rw-r--r-- 1 koka koka 17 2023-03-01 17:31:00.000000000 +0300 file4.txt
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:29:00.000000000 +0300 subdir
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:28:00.000000000 +0300 subdir2

source/subdir:
итого 12
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:29:00.000000000 +0300 .
drwxr-xr-x 4 koka koka 4096 2023-03-01 17:30:00.000000000 +0300 ..
-rw-r--r-- 1 koka koka 27 2023-03-01 17:31:00.000000000 +0300 file2.txt

source/subdir2:
итого 12
drwxr-xr-x 2 koka koka 4096 2023-03-01 17:28:00.000000000 +0300 .
drwxr-xr-x 4 koka koka 4096 2023-03-01 17:30:00.000000000 +0300 ..
-rw-r--r-- 1 koka koka 35 2023-03-01 17:31:00.000000000 +0300 file3.txt

@schollz
Copy link
Owner

schollz commented Nov 19, 2025

Awesome thank you!!

@schollz schollz merged commit 738a80c into schollz:main Nov 19, 2025
1 check failed
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.

2 participants