check for broken symlinks
This commit is contained in:
parent
506f467410
commit
e917234eda
|
@ -391,9 +391,20 @@
|
|||
"source": [
|
||||
"%store -r model_storage_dir\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Check for broken symlinks and remove them\n",
|
||||
"for file in os.listdir('/notebooks/stable-diffusion-webui/models/'):\n",
|
||||
" path = f'/notebooks/stable-diffusion-webui/models/{file}'\n",
|
||||
" if os.path.islink(path) and not os.path.exists(os.readlink(path)):\n",
|
||||
" print(f'Symlink broken, removing: {file}')\n",
|
||||
" os.unlink(path)\n",
|
||||
"\n",
|
||||
"# Make symlinks for new files\n",
|
||||
"for file in os.listdir(model_storage_dir):\n",
|
||||
" if file.endswith(\"ckpt\"):\n",
|
||||
" if not os.path.exists(f'/notebooks/stable-diffusion-webui/models/{file}'):\n",
|
||||
" path = f'/notebooks/stable-diffusion-webui/models/{file}'\n",
|
||||
" if not os.path.exists(path):\n",
|
||||
" print(f'New model: {file}')\n",
|
||||
" !ln -s $model_storage_dir/$file /notebooks/stable-diffusion-webui/models/$file\n",
|
||||
" !ls -la --block-size=GB /notebooks/stable-diffusion-webui/models/$file"
|
||||
]
|
||||
|
@ -494,6 +505,7 @@
|
|||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
|
|
Loading…
Reference in New Issue