From 7c58b5148d58adf1293d9b651d83bc0bc1781e67 Mon Sep 17 00:00:00 2001 From: Rob Date: Sun, 3 May 2020 23:17:58 -0700 Subject: [PATCH] Adding chmod step to write_json_file to keep permissions in line with other files such as description, jpg, and annotations. This is to resolve https://github.com/ytdl-org/youtube-dl/issues/12471 tempfile on linux will make a file that is readonly for the user with all other permission bits turned off. Tempfile is only used for the info.json files. This makes it unique when compared to jpg, annotations, description, and other files that youtube-dl can retrieve or create. --- youtube_dl/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 38262bee4..0f36466ed 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -27,6 +27,7 @@ import random import re import socket import ssl +import stat import subprocess import sys import tempfile @@ -1835,6 +1836,12 @@ def write_json_file(obj, fn): os.unlink(fn) except OSError: pass + os.chmod(tf.name, + stat.S_IRUSR | + stat.S_IWUSR | + stat.S_IRGRP | + stat.S_IROTH) + os.rename(tf.name, fn) except Exception: try: