Fae added a comment.

  As my 'personal' work-around, just for UK legislation PDFs that the API flags 
with chunk-too-small and fails on a second upload, the pdf is trimmed of the 
final byte and re-attempted. In my view this is a terrible hack rather than a 
fix.
  
  However, this initially appears to be working with the files both uploading 
and displaying successfully, though it may later cause unpredictable errors as 
it's hardly an intelligent fix. Ref to this category 
<https://commons.wikimedia.org/w/index.php?title=Category:Work_around_of_byte_trimmed_for_chunk-too-small_API_error>
 for examples.
  
  Code snippet:
  
    rec = uptry(local, fn, dd, comment, False)
    if rec in ['chunk-too-small']:
        print "Chunk-too-small, so trying trimming off 1 byte"
        with open(local, 'rb+') as filehandle:
                filehandle.seek(-1, os.SEEK_END)
                filehandle.truncate()
        rec = uptry(local, fn, dd + "\n[[Category:Work around of byte trimmed 
for chunk-too-small API error]]", comment, False)

TASK DETAIL
  https://phabricator.wikimedia.org/T266117

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Fae
Cc: Mpaa, zhuyifei1999, Aklapper, pywikibot-bugs-list, Fae, JohnsonLee01, 
SHEKH, Dijkstra, CBogen, Khutuck, Zkhalido, Viztor, Wenyi, Ramsey-WMF, Tbscho, 
MayS, Mdupont, JJMC89, Dvorapa, Poyekhali, Altostratus, Taiwania_Justo, 
Avicennasis, Ixocactus, Wong128hk, mys_721tx, El_Grafo, Dinoguy1000, jayvdb, 
Masti, Alchimista, Steinsplitter, Rxy, Keegan
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to