{"record":{"id":"c07b7e63b7af561e","repo":"openmediavault/openmediavault","slug":"cannot-unlink-the-shared-folder-content-because-another","errorCode":null,"errorMessage":"Cannot unlink the shared folder content because another shared folder also refers to it","messagePattern":"Cannot unlink the shared folder content because another shared folder also refers to it","errorType":"exception","errorClass":"OMV\\Exception","httpStatus":null,"severity":"error","filePath":"deb/openmediavault/usr/share/openmediavault/engined/rpc/sharemgmt.inc","lineNumber":609,"sourceCode":"                    \"operator\" => \"stringNotEquals\",\n                    \"arg0\" => \"uuid\",\n                    \"arg1\" => $object->get(\"uuid\")\n                ],\n                \"arg1\" => [\n                    \"operator\" => \"and\",\n                    \"arg0\" => [\n                        \"operator\" => \"stringEquals\",\n                        \"arg0\" => \"mntentref\",\n                        \"arg1\" => $object->get(\"mntentref\")\n                    ],\n                    \"arg1\" => [\n                        \"operator\" => \"stringEquals\",\n                        \"arg0\" => \"reldirpath\",\n                        \"arg1\" => $object->get(\"reldirpath\")\n                    ]\n                ]\n            ])) {\n                throw new \\OMV\\Exception(\"Cannot unlink the shared folder \".\n                  \"content because another shared folder also refers to it\");\n            }\n            // Do not delete the shared folder content if a sub-directory\n            // is part of another shared folder.\n            $sfObjects = $db->getByFilter(\"conf.system.sharedfolder\", [\n                \"operator\" => \"stringEquals\",\n                \"arg0\" => \"mntentref\",\n                \"arg1\" => $object->get(\"mntentref\")\n            ]);\n            if (!empty($sfObjects)) {\n                // Get the mount point configuration object to build the\n                // absolute shared folder path.\n                $meObject = $db->get(\n                    \"conf.system.filesystem.mountpoint\",\n                    $object->get(\"mntentref\")\n                );\n                // Build the absolute shared folder path.\n                $absDirPath = \\OMV\\System\\Os::readlink(build_path(","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/openmediavault/openmediavault/blob/dce610eb66f624c640d0eb7ce401ddd65b763520/deb/openmediavault/usr/share/openmediavault/engined/rpc/sharemgmt.inc#L591-L627","documentation":"sharemgmt::delete (unlink content path) refuses to delete a shared folder's content when a database filter finds another shared folder pointing at the same reldirpath. openmediavault guards against deleting data still referenced by a second shared folder entry. It is a deliberate safety invariant, not a runtime failure.","triggerScenarios":"Calling ShareMgmt::delete (or clicking delete on a shared folder) with the option to remove content, while another shared folder in conf.system.sharedfolder has the identical reldirpath under the same parent.","commonSituations":"Two shared folder entries created for the same directory (e.g. after remounting a disk or duplicating an entry); a stale duplicate entry left after re-creating a filesystem with the same mount path; automation creating shared folders idempotently but with different UUIDs for the same path.","solutions":["List shared folders and find the duplicate entry with the same reldirpath (via WebGUI Storage>Shared Folders or omv-confdbadb read conf.system.sharedfolder).","Delete the duplicate/unneeded shared folder entry first (choose 'not delete content'), then delete the remaining one.","If the duplicate references a dead mount, fix or remove the underlying filesystem/mount entry, refresh, and retry."],"exampleFix":"// before: two SFs -> same path, delete fails\n# omv-confdbadb read conf.system.sharedfolder | grep reldirpath\n// after: remove the duplicate SF entry, then delete\n# omv-confdbadb delete conf.system.sharedfolder <dup-uuid>\n# then delete the remaining shared folder via RPC/UI","handlingStrategy":"validation","validationCode":"const dups = sfs.filter(s => s.reldirpath === target.reldirpath && s.uuid !== target.uuid);\nif (dups.length) throw new Error('duplicate shared folder path: ' + dups.map(d=>d.uuid).join(','));","typeGuard":null,"tryCatchPattern":"try { await rpc('ShareMgmt','delete',params); } catch (e) { if (String(e.message).includes('another shared folder also refers')) { /* resolve duplicate SF entry first */ } else throw e; }","preventionTips":["Before deleting, query conf.system.sharedfolder for entries with the same reldirpath.","Avoid creating multiple shared folder entries for one directory.","Use idempotent automation keyed on path, not just UUID.","Clean up stale entries after re-creating disks/mounts."],"tags":["php","shared-folder","storage","safety-check"],"backgroundTag":"conflicting-config-options","analyzedSha":"dce610eb66f624c640d0eb7ce401ddd65b763520","analyzedAt":"2026-09-15T09:48:09.960Z","contentChangedAt":"2026-09-15T09:48:09.960Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}