Sude- / lgogdownloader

LGOGDownloader is unofficial downloader to GOG.com for Linux users. It uses the same API as the official GOG Galaxy.
https://sites.google.com/site/gogdownloader/
Do What The F*ck You Want To Public License
715 stars 67 forks source link

extras downloaded too often: empty XML #128

Open 0-wiz-0 opened 6 years ago

0-wiz-0 commented 6 years ago

I use lgogdownloader with the following command line:

lgogdownloader --download --repair --game $NAME

I often see it happening that an existing extra is downloaded again, like here:

...
jazz_jackrabbit_collection_en_gog_1_16763.pkg
        MD5:    fe4446803bcf57e1c4832ee1112cd279
        Chunks: 2
        Size:   17180139 bytes

Chunk 1 (6694379 bytes): OK

Repairing file ./jazz_jackrabbit_collection/./jazz_jackrabbit_manual.zip
XML: Using local file
XML: Parsing failed / not valid XML
Filesizes don't match
Incomplete download or different version
Redownloading file
Renaming old file to ./jazz_jackrabbit_collection/./jazz_jackrabbit_manual.zip.20171205T092746.old
Deleting old XML data
100% ▕██████████████████████████▏ 0.07/0.07MB @ 72.75kB/s ETA: 0s
Starting automatic XML creation
jazz_jackrabbit_manual.zip
Filesize: 74500 bytes
Chunks: 1
Chunk size: 10 MB
Getting MD5 for chunks
Chunks hashed 1 / 1
MD5: e67f0a5870d892f79a0afb09b44a8939
Writing XML: /home/wiz/.cache/lgogdownloader/xml/jazz_jackrabbit_collection/jazz_jackrabbit_manual.zip.xml

When I immediately try again, the same thing happens. Looking at the cache file, xml/jazz_jackrabbit_collection/jazz_jackrabbit_manual.zip.xml I see that it is an empty file (0 bytes long). So it seems there is a problem with creating XML files for extras, at least for me. (Perfectly repeatable right now with lgogdownloader from git, version 3.3M.90dcaf0.)

Sude- commented 6 years ago

Does this also create empty xml file

echo asd > test.txt
lgogdownloader --create-xml test.txt
0-wiz-0 commented 6 years ago

yes:

# echo asd > test.txt
# lgogdownloader --create-xml test.txt
test.txt
Filesize: 4 bytes
Chunks: 1
Chunk size: 10 MB
Getting MD5 for chunks
Chunks hashed 1 / 1
MD5: e07910a06a086c83ba41827aa00b26ed
Writing XML: /home/wiz/.cache/lgogdownloader/xml/test.txt.xml
# cat /home/wiz/.cache/lgogdownloader/xml/test.txt.xml
#
Sude- commented 6 years ago

So writing the XML data to file fails for some reason.

Apply this patch: https://sites.google.com/site/gogdownloader/createxml_test.diff and then post the output of

echo asd > test.txt
lgogdownloader --create-xml test.txt
0-wiz-0 commented 6 years ago

In my build environment:

# ./lgogdownloader --create-xml test.txt 
test.txt
Filesize: 4 bytes
Chunks: 1
Chunk size: 10 MB
Getting MD5 for chunks
Chunks hashed 1 / 1
MD5: e07910a06a086c83ba41827aa00b26ed

# 

In a manual build outside this works. I'm confused.

# ./lgogdownloader --create-xml test.txt
test.txt
Filesize: 4 bytes
Chunks: 1
Chunk size: 10 MB
Getting MD5 for chunks
Chunks hashed 1 / 1
MD5: e07910a06a086c83ba41827aa00b26ed
<file name="test.txt" chunks="1" total_size="4" md5="e07910a06a086c83ba41827aa00b26ed">
    <chunk id="0" from="0" to="3" method="md5">e07910a06a086c83ba41827aa00b26ed</chunk>
</file>

The cmake build output looks nearly the same, except for:

@@ -35,76 +37,70 @@
 -- Looking for pthread.h
 -- Looking for pthread.h - found
 -- Looking for pthread_create
--- Looking for pthread_create - found
+-- Looking for pthread_create - not found
+-- Looking for pthread_create in pthreads
+-- Looking for pthread_create in pthreads - not found
+-- Looking for pthread_create in pthread
+-- Looking for pthread_create in pthread - found
 -- Found Threads: TRUE
 -- Found Git: /usr/pkg/bin/git (found version "2.15.1")
+WARNING: One of the following is missing: help2man, gzip; man page will not be generated
 -- Configuring done
 -- Generating done

which doesn't look related.

Sude- commented 6 years ago

This is weird. Do the environments have different versions of libtinyxml2? Has XML creation worked previously or has this been an issue always?

0-wiz-0 commented 6 years ago

I found the difference: When I compile lgogdownloader with:

mkdir build
cd build
cmake -DCMAKE_CXX_FLAGS:STRING="-fstack-check" ..
make

then the XML files end up empty. That's with gcc 5.5.0 on NetBSD/amd64.