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

Fix type error when adding padded bytes. #90

Merged
merged 2 commits into from
Jul 13, 2021

Conversation

rober710
Copy link
Contributor

During recovery of one of the partitions, I got the following error:

WARNING:root:Failed to read byte(s). Padding with 0x00. Offset: 113928912896 Size: 131072
Traceback (most recent call last):
  File "main.py", line 401, in <module>
    main()
  File "main.py", line 398, in main
    interpret(cmd, arguments, parts, shorthands, args.outputdir)
  File "main.py", line 257, in interpret
    restore_part(i, parts, shorthands, -1, outdir)
  File "main.py", line 278, in restore_part
    logic.recursive_restore(myfile, part, partition_dir)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 259, in recursive_restore
    recursive_restore(child, part, outputdir, make_dirs=False)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 259, in recursive_restore
    recursive_restore(child, part, outputdir, make_dirs=False)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 259, in recursive_restore
    recursive_restore(child, part, outputdir, make_dirs=False)
  [Previous line repeated 1 more time]
  File "/home/Rober/Programas/RecuperaBit/recuperabit/logic.py", line 245, in recursive_restore
    for piece in content:
  File "/home/Rober/Programas/RecuperaBit/recuperabit/fs/ntfs.py", line 366, in content_iterator
    partial = self._padded_bytes(image, position, amount)
  File "/home/Rober/Programas/RecuperaBit/recuperabit/fs/ntfs.py", line 322, in _padded_bytes
    dump += bytearray('\x00' * (size - len(dump)))
TypeError: string argument without an encoding

This PR just prefixes the string with b to convert it to a bytes instance instead of str, so that the function doesn't require an encoding.

.gitignore Outdated
@@ -4,6 +4,9 @@
!.vscode/launch.json
*.code-workspace

# PyCharm
.idea/
Copy link
Contributor

Choose a reason for hiding this comment

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

ideally this kind of line should be done on your general .gitignore, not the project's gitignore (but honestly it's not a big deal). Because the project itself doesn't generate any .idea folder, and we don't want to clutter the .gitignore with all the editor specific things that might be needed.

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 added it since I saw that there are vscode exclusions just above. I removed the change to the .gitignore file and added to my local exclusions file instead.

@Lazza
Copy link
Owner

Lazza commented Jul 13, 2021

Sorry that I left this opened a bit too much. Thanks for your contribution!

@Lazza Lazza merged commit 728e978 into Lazza:master Jul 13, 2021
@rober710 rober710 deleted the fix-type-error-padding branch July 15, 2021 06:41
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