Skip to content
Permalink
Browse files

Merge branch 'dev'

  • Loading branch information...
fffonion committed Mar 27, 2019
2 parents 5a30109 + 79da83e commit c431b053709a8335b2b87b44a40e09b3a90ba672
Showing with 36 additions and 9 deletions.
  1. +8 −2 .travis.yml
  2. +2 −2 xeHentai/const.py
  3. +20 −3 xeHentai/task.py
  4. +6 −2 xeHentai/util/__init__.py
@@ -1,14 +1,20 @@
os:
- linux
- windows

language: python
sudo: required
dist: xenial
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
- 3.7

matrix:
include:
- python: 3.3
dist: trusty

install:
- python setup.py install
@@ -13,11 +13,11 @@
IRONPYTHON = sys.platform == 'cli'
EXEBUNDLE = getattr(sys, 'frozen', False)
LOCALE = locale.getdefaultlocale()[0]
CODEPAGE = locale.getdefaultlocale()[1]
CODEPAGE = locale.getdefaultlocale()[1] or 'ascii'
ANDROID = 'ANDROID_ARGUMENT' in os.environ

__version__ = 2.020
DEVELOPMENT = True
DEVELOPMENT = False

SCRIPT_NAME = "xeHentai"

@@ -10,6 +10,7 @@
import uuid
import shutil
import zipfile
import tempfile
from threading import RLock
from . import util
from .const import *
@@ -216,20 +217,36 @@ def save_file(self, imgurl, redirect_url, binary_iter):
# create a femp file first
# we don't need _f_lock because this will not be in a sequence
# and we can't do that otherwise we are breaking the multi threading
fn_tmp = os.path.join(fpath, ".%s.xeh" % self.get_fidpad(int(fid)))
fd_tmp, fn_tmp = tempfile.mkstemp(prefix="xehentai-")
os.close(fd_tmp)
try:
with open(fn_tmp, "wb") as f:
for binary in binary_iter():
if self._monitor._exit(None):
raise DownloadAbortedException()
f.write(binary)
except DownloadAbortedException as ex:
os.remove(fn_tmp)
try:
os.unlink(fn_tmp)
except:
pass
return

self._f_lock.acquire()
try:
os.rename(fn_tmp, fn)
try:
os.rename(fn_tmp, fn)
except WindowsError as ex:
# file is used by another process
# do a copy and delete, WindowsError[32]
if ex.errno == 13:
shutil.copy(fn_tmp, fn)
try:
os.unlink(fn_tmp)
except:
pass
else:
raise ex
self._cnt_lock.acquire()
self.meta['finished'] += 1
self._cnt_lock.release()
@@ -12,7 +12,7 @@
from ..const import *

if os.name == 'nt':
filename_filter = re.compile("[|:?\\/*'\"<>]|\.(?:$)")
filename_filter = re.compile("[|:?\\/*'\"<>]|\.+(?:$)")
else:# assume posix
filename_filter = re.compile("[\/:]")

@@ -79,4 +79,8 @@ def replc(match):
return htmlre.sub(replc, s)

def legalpath(s):
return filename_filter.sub(lambda x:"", s)
sanitized = filename_filter.sub(lambda x:"", s)
# windows doesn't like trailing while spaces
if os.name == 'nt':
sanitized = sanitized.rstrip()
return sanitized

0 comments on commit c431b05

Please sign in to comment.
You can’t perform that action at this time.