prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Tails 3.0 does not restore the original filename when uncompressing a file
  # Bug
  
  Tails 3.0 does not preserve the filename when extracting an archive.
  
  ## Description
  
  When extracting an archive, Tails 3.0 will rename the file inside the archive to _data_.
  
  ## Steps to Reproduce
  
  Download a SecureDrop submission, decrypt the submission and extract the archive.
  
  ## Expected Behavior
  
  Tails should preserve the filename and leave you with, say, _code_name.pdf_.
  
  ## Actual Behavior
  
  Tails 3.0 leaves you with a file called _data_ instead.
  
  ## Comments
  
  I suspect this is an issue with Tails 3.0 and not the way SecureDrop creates the archive in the first place. Filing here just in case.
  
  </issue>
  <code>
  [start of install_files/ansible-base/roles/tails-config/files/securedrop_init.py]
  1 #!/usr/bin/python
  2 
  3 import os
  4 import sys
  5 import subprocess
  6 
  7 
  8 # check for root
  9 if os.geteuid() != 0:
  10     sys.exit('You need to run this as root')
  11 
  12 # paths
  13 path_torrc_additions = '/home/amnesia/Persistent/.securedrop/torrc_additions'
  14 path_torrc_backup = '/etc/tor/torrc.bak'
  15 path_torrc = '/etc/tor/torrc'
  16 
  17 # load torrc_additions
  18 if os.path.isfile(path_torrc_additions):
  19     torrc_additions = open(path_torrc_additions).read()
  20 else:
  21     sys.exit('Error opening {0} for reading'.format(path_torrc_additions))
  22 
  23 # load torrc
  24 if os.path.isfile(path_torrc_backup):
  25     torrc = open(path_torrc_backup).read()
  26 else:
  27     if os.path.isfile(path_torrc):
  28         torrc = open(path_torrc).read()
  29     else:
  30         sys.exit('Error opening {0} for reading'.format(path_torrc))
  31 
  32     # save a backup
  33     open(path_torrc_backup, 'w').write(torrc)
  34 
  35 # append the additions
  36 open(path_torrc, 'w').write(torrc + torrc_additions)
  37 
  38 # reload tor
  39 try:
  40     subprocess.check_call(['systemctl', 'reload', 'tor@default.service'])
  41 except subprocess.CalledProcessError:
  42     sys.exit('Error reloading Tor')
  43 
  44 # notify the user
  45 subprocess.call(['tails-notify-user',
  46                  'SecureDrop successfully auto-configured!',
  47                  'You can now access the Journalist Interface.\nIf you are an admin, you can now SSH to the servers.'])
  48
  [end of install_files/ansible-base/roles/tails-config/files/securedrop_init.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/install_files/ansible-base/roles/tails-config/files/securedrop_init.py b/install_files/ansible-base/roles/tails-config/files/securedrop_init.py
  --- a/install_files/ansible-base/roles/tails-config/files/securedrop_init.py
  +++ b/install_files/ansible-base/roles/tails-config/files/securedrop_init.py
  @@ -41,6 +41,13 @@
   except subprocess.CalledProcessError:
       sys.exit('Error reloading Tor')
   
  +# Turn off "automatic-decompression" in Nautilus to ensure the original
  +# submission filename is restored (see
  +# https://github.com/freedomofpress/securedrop/issues/1862#issuecomment-311519750).
  +subprocess.call(['/usr/bin/dconf', 'write',
  +                 '/org/gnome/nautilus/preferences/automatic-decompression',
  +                 'false'])
  +
   # notify the user
   subprocess.call(['tails-notify-user',
                    'SecureDrop successfully auto-configured!',
  
verification_info: {"golden_diff": "diff --git a/install_files/ansible-base/roles/tails-config/files/securedrop_init.py b/install_files/ansible-base/roles/tails-config/files/securedrop_init.py\n--- a/install_files/ansible-base/roles/tails-config/files/securedrop_init.py\n+++ b/install_files/ansible-base/roles/tails-config/files/securedrop_init.py\n@@ -41,6 +41,13 @@\n except subprocess.CalledProcessError:\n     sys.exit('Error reloading Tor')\n \n+# Turn off \"automatic-decompression\" in Nautilus to ensure the original\n+# submission filename is restored (see\n+# https://github.com/freedomofpress/securedrop/issues/1862#issuecomment-311519750).\n+subprocess.call(['/usr/bin/dconf', 'write',\n+                 '/org/gnome/nautilus/preferences/automatic-decompression',\n+                 'false'])\n+\n # notify the user\n subprocess.call(['tails-notify-user',\n                  'SecureDrop successfully auto-configured!',\n", "issue": "Tails 3.0 does not restore the original filename when uncompressing a file\n# Bug\r\n\r\nTails 3.0 does not preserve the filename when extracting an archive.\r\n\r\n## Description\r\n\r\nWhen extracting an archive, Tails 3.0 will rename the file inside the archive to _data_.\r\n\r\n## Steps to Reproduce\r\n\r\nDownload a SecureDrop submission, decrypt the submission and extract the archive.\r\n\r\n## Expected Behavior\r\n\r\nTails should preserve the filename and leave you with, say, _code_name.pdf_.\r\n\r\n## Actual Behavior\r\n\r\nTails 3.0 leaves you with a file called _data_ instead.\r\n\r\n## Comments\r\n\r\nI suspect this is an issue with Tails 3.0 and not the way SecureDrop creates the archive in the first place. Filing here just in case.\n", "before_files": [{"content": "#!/usr/bin/python\n\nimport os\nimport sys\nimport subprocess\n\n\n# check for root\nif os.geteuid() != 0:\n    sys.exit('You need to run this as root')\n\n# paths\npath_torrc_additions = '/home/amnesia/Persistent/.securedrop/torrc_additions'\npath_torrc_backup = '/etc/tor/torrc.bak'\npath_torrc = '/etc/tor/torrc'\n\n# load torrc_additions\nif os.path.isfile(path_torrc_additions):\n    torrc_additions = open(path_torrc_additions).read()\nelse:\n    sys.exit('Error opening {0} for reading'.format(path_torrc_additions))\n\n# load torrc\nif os.path.isfile(path_torrc_backup):\n    torrc = open(path_torrc_backup).read()\nelse:\n    if os.path.isfile(path_torrc):\n        torrc = open(path_torrc).read()\n    else:\n        sys.exit('Error opening {0} for reading'.format(path_torrc))\n\n    # save a backup\n    open(path_torrc_backup, 'w').write(torrc)\n\n# append the additions\nopen(path_torrc, 'w').write(torrc + torrc_additions)\n\n# reload tor\ntry:\n    subprocess.check_call(['systemctl', 'reload', 'tor@default.service'])\nexcept subprocess.CalledProcessError:\n    sys.exit('Error reloading Tor')\n\n# notify the user\nsubprocess.call(['tails-notify-user',\n                 'SecureDrop successfully auto-configured!',\n                 'You can now access the Journalist Interface.\\nIf you are an admin, you can now SSH to the servers.'])\n", "path": "install_files/ansible-base/roles/tails-config/files/securedrop_init.py"}]}