Don't delete lnks that have empty string path.
This commit is contained in:
parent
16f324ff78
commit
3d61b3b1ec
1 changed files with 11 additions and 0 deletions
|
@ -14,6 +14,17 @@ from voussoirkit import pathclass
|
||||||
def prune_shortcuts(autoyes=False):
|
def prune_shortcuts(autoyes=False):
|
||||||
lnks = pathclass.Path('.').glob('*.lnk')
|
lnks = pathclass.Path('.').glob('*.lnk')
|
||||||
stale = [lnk for lnk in lnks if not os.path.exists(winshell.Shortcut(lnk.absolute_path).path)]
|
stale = [lnk for lnk in lnks if not os.path.exists(winshell.Shortcut(lnk.absolute_path).path)]
|
||||||
|
stale = []
|
||||||
|
for lnk in lnks:
|
||||||
|
shortcut = winshell.Shortcut(lnk.absolute_path)
|
||||||
|
# There are some special shortcuts that do not have a path, but instead
|
||||||
|
# trigger some action based on a CLSID that Explorer understands.
|
||||||
|
# I can't find this information in the winshell.Shortcut object, so for
|
||||||
|
# now let's at least not delete these files.
|
||||||
|
if shortcut.path == '':
|
||||||
|
continue
|
||||||
|
if not os.path.exists(shortcut.path):
|
||||||
|
stale.append(lnk)
|
||||||
|
|
||||||
if not stale:
|
if not stale:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue