From 8172e74caf399031bacd17e94a304ee2dcf736a5 Mon Sep 17 00:00:00 2001 From: paboum Date: Sun, 11 Aug 2024 23:01:26 +0200 Subject: [PATCH] Find max path length on current system Needed for https://github.com/ytdl-org/youtube-dl/issues/29912 --- bin/youtube-dl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/youtube-dl b/bin/youtube-dl index fc3cc8ad889..60d0fdcbb97 100755 --- a/bin/youtube-dl +++ b/bin/youtube-dl @@ -2,5 +2,18 @@ import youtube_dl +import os + +MAX_LENGTH = 0 + +for i in range(1000): + try: + os.stat('a' * i) + except FileNotFoundError: + pass + except OSError: + MAX_LENGTH = i - 1 + break + if __name__ == '__main__': youtube_dl.main()