kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Merge branch 'import-eaccess-fix' into 'develop'
Handle access errors scanning directories See merge request funkwhale/funkwhale!1149environments/review-docs-devel-1399dq/deployments/6607
commit
fe0ed1f040
|
@ -3,6 +3,7 @@ import datetime
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
@ -29,16 +30,27 @@ def crawl_dir(dir, extensions, recursive=True, ignored=[]):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
scanner = os.scandir(dir)
|
scanner = os.scandir(dir)
|
||||||
|
except Exception as e:
|
||||||
|
m = "Error while reading {}: {} {}\n".format(dir, e.__class__.__name__, e)
|
||||||
|
sys.stderr.write(m)
|
||||||
|
return
|
||||||
|
try:
|
||||||
for entry in scanner:
|
for entry in scanner:
|
||||||
if entry.is_file():
|
try:
|
||||||
for e in extensions:
|
if entry.is_file():
|
||||||
if entry.name.lower().endswith(".{}".format(e.lower())):
|
for e in extensions:
|
||||||
if entry.path not in ignored:
|
if entry.name.lower().endswith(".{}".format(e.lower())):
|
||||||
yield entry.path
|
if entry.path not in ignored:
|
||||||
elif recursive and entry.is_dir():
|
yield entry.path
|
||||||
yield from crawl_dir(
|
elif recursive and entry.is_dir():
|
||||||
entry.path, extensions, recursive=recursive, ignored=ignored
|
yield from crawl_dir(
|
||||||
|
entry.path, extensions, recursive=recursive, ignored=ignored
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
m = "Error while reading {}: {} {}\n".format(
|
||||||
|
entry.name, e.__class__.__name__, e
|
||||||
)
|
)
|
||||||
|
sys.stderr.write(m)
|
||||||
finally:
|
finally:
|
||||||
if hasattr(scanner, "close"):
|
if hasattr(scanner, "close"):
|
||||||
scanner.close()
|
scanner.close()
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Handle access errors scanning directories when importing files
|
Ładowanie…
Reference in New Issue