1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-24 18:47:23 +00:00

Fix #969 (duplicate code "init" in epub reader)

Fix for #890
This commit is contained in:
Ozzieisaacs 2019-07-23 19:09:16 +02:00
parent 97a0dccdec
commit fc4dc36c65
2 changed files with 18 additions and 33 deletions

View File

@ -79,15 +79,6 @@
</div>
<div class="overlay"></div>
<script type="text/javascript">
window.calibre = {
filePath: "{{ url_for('static', filename='js/libs/') }}",
cssPath: "{{ url_for('static', filename='css/') }}",
bookmarkUrl: "{{ url_for('bookmark', book_id=bookid, book_format='EPUB') }}",
bookUrl: "{{ url_for('get_download_link_ext', book_id=bookid, book_format="epub", anyname='file.epub') }}",
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
useBookmarks: {{ g.user.is_authenticated | tojson }} };
</script>
<script src="{{ url_for('static', filename='js/libs/jszip.min.js') }}">
</script> <script src="{{ url_for('static', filename='js/libs/epub.min.js') }}"></script>
<script type="text/javascript">

View File

@ -187,16 +187,16 @@ class WorkerThread(threading.Thread):
self.UIqueue = list()
self.asyncSMTP = None
self.id = 0
self.doLock = threading.Lock()
# Main thread loop starting the different tasks
def run(self):
main_thread = _get_main_thread()
while main_thread.is_alive():
doLock = threading.Lock()
doLock.acquire()
self.doLock.acquire()
if self.current != self.last:
index = self.current
doLock.release()
self.doLock.release()
if self.queue[index]['taskType'] == TASK_EMAIL:
self._send_raw_email()
if self.queue[index]['taskType'] == TASK_CONVERT:
@ -204,11 +204,11 @@ class WorkerThread(threading.Thread):
if self.queue[index]['taskType'] == TASK_CONVERT_ANY:
self._convert_any_format()
# TASK_UPLOAD is handled implicitly
doLock.acquire()
self.doLock.acquire()
self.current += 1
doLock.release()
self.doLock.release()
else:
doLock.release()
self.doLock.release()
if main_thread.is_alive():
time.sleep(1)
@ -229,8 +229,7 @@ class WorkerThread(threading.Thread):
self.last = len(self.queue)
def get_taskstatus(self):
doLock = threading.Lock()
doLock.acquire()
self.doLock.acquire()
if self.current < len(self.queue):
if self.UIqueue[self.current]['stat'] == STAT_STARTED:
if self.queue[self.current]['taskType'] == TASK_EMAIL:
@ -239,15 +238,14 @@ class WorkerThread(threading.Thread):
self.UIqueue[self.current]['rt'] = self.UIqueue[self.current]['formRuntime'].days*24*60 \
+ self.UIqueue[self.current]['formRuntime'].seconds \
+ self.UIqueue[self.current]['formRuntime'].microseconds
doLock.release()
self.doLock.release()
return self.UIqueue
def _convert_any_format(self):
# convert book, and upload in case of google drive
doLock = threading.Lock()
doLock.acquire()
self.doLock.acquire()
index = self.current
doLock.release()
self.doLock.release()
self.UIqueue[index]['stat'] = STAT_STARTED
self.queue[index]['starttime'] = datetime.now()
self.UIqueue[index]['formStarttime'] = self.queue[self.current]['starttime']
@ -264,10 +262,9 @@ class WorkerThread(threading.Thread):
def _convert_ebook_format(self):
error_message = None
doLock = threading.Lock()
doLock.acquire()
self.doLock.acquire()
index = self.current
doLock.release()
self.doLock.release()
file_path = self.queue[index]['file_path']
bookid = self.queue[index]['bookid']
format_old_ext = u'.' + self.queue[index]['settings']['old_book_format'].lower()
@ -444,10 +441,9 @@ class WorkerThread(threading.Thread):
def _send_raw_email(self):
doLock = threading.Lock()
doLock.acquire()
self.doLock.acquire()
index = self.current
doLock.release()
self.doLock.release()
self.queue[index]['starttime'] = datetime.now()
self.UIqueue[index]['formStarttime'] = self.queue[index]['starttime']
self.UIqueue[index]['stat'] = STAT_STARTED
@ -524,20 +520,18 @@ class WorkerThread(threading.Thread):
def _handleError(self, error_message):
log.error(error_message)
doLock = threading.Lock()
doLock.acquire()
self.doLock.acquire()
index = self.current
doLock.release()
self.doLock.release()
self.UIqueue[index]['stat'] = STAT_FAIL
self.UIqueue[index]['progress'] = "100 %"
self.UIqueue[index]['formRuntime'] = datetime.now() - self.queue[self.current]['starttime']
self.UIqueue[index]['message'] = error_message
def _handleSuccess(self):
doLock = threading.Lock()
doLock.acquire()
self.doLock.acquire()
index = self.current
doLock.release()
self.doLock.release()
self.UIqueue[index]['stat'] = STAT_FINISH_SUCCESS
self.UIqueue[index]['progress'] = "100 %"
self.UIqueue[index]['formRuntime'] = datetime.now() - self.queue[self.current]['starttime']