Skip to content

Commit 941fb16

Browse files
committed
webdir: skip fs scan if not --filesystem flag
1 parent 14a5eda commit 941fb16

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

xklb/scripts/web_add.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,34 @@ def spider(args, paths: Set):
248248
else:
249249
new_paths[path] = None # add key to map; title: None
250250

251-
media = [{"path": k, "title": v} for k, v in new_paths.items()]
251+
media = [
252+
{
253+
"path": k,
254+
"title": v,
255+
"time_created": consts.APPLICATION_START,
256+
"time_deleted": 0,
257+
}
258+
for k, v in new_paths.items()
259+
]
252260
new_media_count += len(media)
253261
for i, m in enumerate(media, start=1):
254262
printing.print_overwrite(
255263
f"Pages to scan {len(paths)} link scan: {new_media_count} new [{len(known_paths)} known]; basic metadata {i} of {len(media)}"
256264
)
257265

258-
m |= web.stat(m["path"])
259-
m["type"] = file_utils.mimetype(m["path"])
266+
if DBType.filesystem in args.profiles:
267+
m |= web.stat(m["path"])
268+
m["type"] = file_utils.mimetype(m["path"])
269+
else:
270+
extension = m["path"].rsplit(".", 1)[-1].lower()
271+
if (
272+
args.scan_all_files
273+
or (DBType.video in args.profiles and extension in consts.VIDEO_EXTENSIONS)
274+
or (DBType.audio in args.profiles and extension in consts.AUDIO_ONLY_EXTENSIONS)
275+
or (DBType.text in args.profiles and extension in consts.TEXTRACT_EXTENSIONS)
276+
or (DBType.image in args.profiles and extension in consts.IMAGE_EXTENSIONS)
277+
):
278+
m |= web.stat(m["path"])
260279

261280
if getattr(args, "hash", False):
262281
# TODO: use head_foot_stream
@@ -268,6 +287,7 @@ def spider(args, paths: Set):
268287
)
269288

270289
extension = m["path"].rsplit(".", 1)[-1].lower()
290+
271291
remote_path = m["path"] # for temp file extraction
272292
if DBType.video in args.profiles and (extension in consts.VIDEO_EXTENSIONS or args.scan_all_files):
273293
m |= av.munge_av_tags(args, m["path"])

xklb/utils/web.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def requests_session(args=argparse.Namespace()):
9797
def stat(path):
9898
try:
9999
r = requests_session().head(path)
100-
info = {"time_created": consts.APPLICATION_START, "time_deleted": 0}
100+
info = {}
101101

102102
if 200 <= r.status_code < 400:
103103
if "content-length" in r.headers:

0 commit comments

Comments
 (0)