mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[models/downloader] Add task flag to make file executable
This commit is contained in:
parent
c9f9d38f1b
commit
d0d37c40e7
|
@ -352,6 +352,9 @@ class DLManager(Process):
|
||||||
self.tasks.extend(chunk_tasks)
|
self.tasks.extend(chunk_tasks)
|
||||||
self.tasks.append(FileTask(current_file.filename, flags=TaskFlags.CLOSE_FILE))
|
self.tasks.append(FileTask(current_file.filename, flags=TaskFlags.CLOSE_FILE))
|
||||||
|
|
||||||
|
if current_file.executable:
|
||||||
|
self.tasks.append(FileTask(current_file.filename, flags=TaskFlags.MAKE_EXECUTABLE))
|
||||||
|
|
||||||
# check if runtime cache size has changed
|
# check if runtime cache size has changed
|
||||||
if current_cache_size > last_cache_size:
|
if current_cache_size > last_cache_size:
|
||||||
self.log.debug(f' * New maximum cache size: {current_cache_size / 1024 / 1024:.02f} MiB')
|
self.log.debug(f' * New maximum cache size: {current_cache_size / 1024 / 1024:.02f} MiB')
|
||||||
|
|
|
@ -230,6 +230,21 @@ class FileWorker(Process):
|
||||||
|
|
||||||
self.o_q.put(WriterTaskResult(success=True, **j.__dict__))
|
self.o_q.put(WriterTaskResult(success=True, **j.__dict__))
|
||||||
continue
|
continue
|
||||||
|
elif j.flags & TaskFlags.MAKE_EXECUTABLE:
|
||||||
|
if current_file:
|
||||||
|
logger.warning('Trying to chmod file without closing first!')
|
||||||
|
current_file.close()
|
||||||
|
current_file = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
st = os.stat(full_path)
|
||||||
|
os.chmod(full_path, st.st_mode | 0o111)
|
||||||
|
except OSError as e:
|
||||||
|
if not j.flags & TaskFlags.SILENT:
|
||||||
|
logger.error(f'chmod\'ing file failed: {e!r}')
|
||||||
|
|
||||||
|
self.o_q.put(WriterTaskResult(success=True, **j.__dict__))
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if j.shared_memory:
|
if j.shared_memory:
|
||||||
|
|
|
@ -62,6 +62,7 @@ class TaskFlags(Flag):
|
||||||
CREATE_EMPTY_FILE = auto()
|
CREATE_EMPTY_FILE = auto()
|
||||||
RENAME_FILE = auto()
|
RENAME_FILE = auto()
|
||||||
RELEASE_MEMORY = auto()
|
RELEASE_MEMORY = auto()
|
||||||
|
MAKE_EXECUTABLE = auto()
|
||||||
SILENT = auto()
|
SILENT = auto()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue