Browse Source

Fix download confirm and buffer for .Z files.

master
Alec Murphy 5 years ago
parent
commit
69441f0596
  1. 7
      Uriel.HC
  2. 12
      uriel.py

7
Uriel.HC

@ -117,6 +117,7 @@ U0 U_Download(U8 *url)
{
I64 size;
U8 localfile[StrLen(URIEL_DL_PATH)+28];
U8 msg[128];
StrCpy(localfile,URIEL_DL_PATH);
if (StrLen(StrLastOcc(url,"/")+1)>0) {
StrCpy(localfile+StrLen(localfile), StrLastOcc(url,"/")+1);
@ -133,7 +134,7 @@ U0 U_Download(U8 *url)
};
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
if (StrCmp(localfile+StrLen(localfile)-2,".Z")==0) {
U8 uzlocalfile[28];
U8 uzlocalfile[StrLen(URIEL_DL_PATH)+28];
MemCpy(uzlocalfile,localfile,StrLen(localfile)-2);
uzlocalfile[StrLen(localfile)-1] = 0x0;
FileWrite(uzlocalfile, HGFS_BUF, size);
@ -141,7 +142,9 @@ U0 U_Download(U8 *url)
} else {
FileWrite(localfile, HGFS_BUF, size);
};
PopUpOk("Downloaded file: %s", localfile);
StrCpy(msg, "Downloaded file: ");
StrCpy(msg+StrLen(msg), localfile);
PopUpOk(msg);
}
U0 U_Navigate(U8 *anchor, U8 *url) {

12
uriel.py

@ -64,6 +64,18 @@ def UrielGetPage():
if filesize>0:
if filedata.find('$AN,"",A="BINARY"$') != -1:
Uriel.download_buffer = pagedata
if url[-2:].upper()==".Z":
tmp_z_file = "/tmp/" + str(uuid.uuid4()).split('-')[0].upper() + ".Z"
while os.path.exists(tmp_z_file):
tmp_z_file = "/tmp/" + str(uuid.uuid4()).split('-')[0].upper() + ".Z"
open(tmp_z_file,"wb").write(pagedata)
try:
os.system('tosz "' + tmp_z_file + '"')
pagedata = open(tmp_z_file.split('.Z')[0],"rb").read()
os.remove(tmp_z_file.split('.Z')[0])
Uriel.download_buffer = pagedata
except:
Uriel.download_buffer = ''
Uriel.nav_index += 1
Uriel.history = Uriel.history[0:Uriel.nav_index]
Uriel.history.append({'url':url, 'filedata':filedata})

Loading…
Cancel
Save