markokr/rarfile

Failed the read enough data

Opened this issue · 0 comments

This is my code. It works fine without a password for rar, but gives an error when there is a password (the password is 100% correct). The problem is that when I create the rar myself and put a password, it works fine. However, it does not work with some rars that I downloaded from the internet with passwords.
Failed the read enough data: req=7661 got=0

`
import rarfile

rar_dosyasi_yolu = "testrar.rar"
rarfile.UNRAR_TOOL = "UnRAR.exe"
rf = rarfile.RarFile(rar_dosyasi_yolu)

for info in rf.infolist():
print(f"File: {info.filename}, Size: {info.file_size} bytes")
if info.file_size > 0:
try:
with rf.open(info, pwd=b'testrar') as dosya:
icerik = dosya.read()
print(icerik)
except rarfile.RarWrongPassword:
print("Yanlış şifre!")
except rarfile.RarCRCError:
print("CRC hatası! Dosya bozuk olabilir.")
except Exception as e:
print(f"Dosya açılırken hata oluştu: {e}") # Failed the read enough data: req=7661 got=0
else:
print("Dosya boyutu 0, bu dosya boş olabilir.")
`