Fix ensures internal buffer of a downloaded file is written to disk.

This commit is contained in:
Prinz23 2016-03-15 17:34:58 +01:00 committed by JackDandy
parent d68fe420e7
commit e55462f47b
4 changed files with 37 additions and 4 deletions

View file

@ -1,4 +1,9 @@
### 0.11.7 (2016-03-06 12:30:00 UTC)
### 0.11.8 (2016-03-16 12:50:00 UTC)
* Fix ensures internal buffer of a downloaded file is written to disk
### 0.11.7 (2016-03-06 12:30:00 UTC)
* Fix Torrenting provider

View file

@ -977,6 +977,18 @@ class Migrate41(db.SchemaUpgrade):
return self.checkDBVersion()
# 4301 -> 10001
class Migrate4301(db.SchemaUpgrade):
def execute(self):
db.backup_database('sickbeard.db', self.checkDBVersion())
logger.log(u'Dropping redundant column')
self.dropColumn('db_version', 'db_minor_version')
self.setDBVersion(10001)
return self.checkDBVersion()
# 5816 - 5818 -> 15
class MigrateUpstream(db.SchemaUpgrade):
def execute(self):
@ -1046,4 +1058,4 @@ class AddTvShowTags(db.SchemaUpgrade):
self.addColumn('tv_shows', 'tag', 'TEXT', 'Show List')
self.setDBVersion(20003)
return self.checkDBVersion()
return self.checkDBVersion()

View file

@ -28,6 +28,7 @@ import sickbeard
from sickbeard import encodingKludge as ek
from sickbeard import logger
from sickbeard.exceptions import ex
import helpers
db_lock = threading.Lock()
@ -48,8 +49,15 @@ def dbFilename(filename='sickbeard.db', suffix=None):
class DBConnection(object):
def __init__(self, filename='sickbeard.db', suffix=None, row_type=None):
db_src = dbFilename(filename)
if not os.path.isfile(db_src):
db_alt = dbFilename('sickrage.db')
if os.path.isfile(db_alt):
helpers.copyFile(db_alt, db_src)
self.filename = filename
self.connection = sqlite3.connect(dbFilename(filename), 20)
self.connection = sqlite3.connect(db_src, 20)
if row_type == 'dict':
self.connection.row_factory = self._dict_factory
@ -67,6 +75,9 @@ class DBConnection(object):
return 0
if result:
if self.hasColumn('db_version', 'db_minor_version'):
minor = self.select('SELECT db_minor_version FROM db_version')
return int(result[0]['db_version']) * 100 + int(minor[0]['db_minor_version'])
return int(result[0]['db_version'])
else:
return 0
@ -411,6 +422,10 @@ def MigrationCode(myDB):
40: sickbeard.mainDB.BumpDatabaseVersion,
41: sickbeard.mainDB.Migrate41,
42: sickbeard.mainDB.Migrate41,
43: sickbeard.mainDB.Migrate41,
44: sickbeard.mainDB.Migrate41,
4301: sickbeard.mainDB.Migrate4301,
5816: sickbeard.mainDB.MigrateUpstream,
5817: sickbeard.mainDB.MigrateUpstream,
@ -457,4 +472,4 @@ def backup_database(filename, version):
if not sickbeard.helpers.backupVersionedFile(dbFilename(filename), version):
logger.log_error_and_exit(u'Database backup failed, abort upgrading database')
else:
logger.log(u'Proceeding with upgrade')
logger.log(u'Proceeding with upgrade')

View file

@ -1235,6 +1235,7 @@ def download_file(url, filename, session=None):
if chunk:
fp.write(chunk)
fp.flush()
os.fsync(fp.fileno())
chmodAsParent(filename)
except requests.exceptions.HTTPError as e: