fix double drive_c issues
This commit is contained in:
parent
3e054dd9de
commit
f2145d6678
7 changed files with 73 additions and 33 deletions
|
|
@ -41,22 +41,39 @@ function prefixExists(name) {
|
|||
}
|
||||
}
|
||||
|
||||
// Where the Windows C: drive of a prefix actually lives: plain wine keeps
|
||||
// it at the top (WINEPREFIX=<prefix>), Proton-managed prefixes nest it
|
||||
// under pfx/ (WINEPREFIX=<prefix>/pfx). system.reg marks the real prefix
|
||||
// root; a fresh prefix may not have it yet, so fall back to drive_c itself.
|
||||
function prefixDriveRoot(name) {
|
||||
// Every Windows C: drive a prefix has: plain wine keeps one at the top
|
||||
// (WINEPREFIX=<prefix>), Proton-managed prefixes nest one under pfx/
|
||||
// (WINEPREFIX=<prefix>/pfx). A prefix used with BOTH wine kinds has both,
|
||||
// and an import may come from either one - so callers that can accept
|
||||
// several get them all, top level first.
|
||||
function prefixDriveRoots(name) {
|
||||
const root = prefixPath(name)
|
||||
for (const pass of [true, false]) {
|
||||
for (const base of [root, path.join(root, 'pfx')]) {
|
||||
try {
|
||||
const driveC = path.join(base, 'drive_c')
|
||||
if (!fs.statSync(driveC).isDirectory()) continue
|
||||
if (!pass || fs.existsSync(path.join(base, 'system.reg'))) return driveC
|
||||
} catch {}
|
||||
}
|
||||
const found = []
|
||||
for (const base of [root, path.join(root, 'pfx')]) {
|
||||
try {
|
||||
const driveC = path.join(base, 'drive_c')
|
||||
if (fs.statSync(driveC).isDirectory()) found.push(driveC)
|
||||
} catch {}
|
||||
}
|
||||
return null
|
||||
return found
|
||||
}
|
||||
|
||||
// True when a path IS one of a prefix's own roots: the prefix folder, its
|
||||
// pfx/ or either drive_c. A copy/move import of such a folder would move the
|
||||
// prefix's C: drive (or the whole prefix) into files/apps, gutting it - the
|
||||
// "import from a prefix" flow is the one that works in place. Both drive
|
||||
// layouts are checked literally, not through prefixDriveRoots(): a prefix used
|
||||
// with wine AND Proton has a drive_c each and BOTH are off limits.
|
||||
function isPrefixRoot(p) {
|
||||
if (!p) return false
|
||||
const abs = path.resolve(String(p))
|
||||
if (path.resolve(DIRS.PREFIXES) === abs) return true
|
||||
for (const entry of listPrefixes().prefixes) {
|
||||
const root = prefixPath(entry.name)
|
||||
if (abs === root || abs === path.join(root, 'pfx')) return true
|
||||
if (abs === path.join(root, 'drive_c') || abs === path.join(root, 'pfx', 'drive_c')) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function createPrefix(name) {
|
||||
|
|
@ -136,4 +153,4 @@ function setDefaultPrefix(name) {
|
|||
return { ok: true }
|
||||
}
|
||||
|
||||
module.exports = { listPrefixes, savePrefixes, createPrefix, deletePrefix, renamePrefix, setDefaultPrefix, prefixPath, prefixExists, prefixDriveRoot, healPrefix, MAIN }
|
||||
module.exports = { listPrefixes, savePrefixes, createPrefix, deletePrefix, renamePrefix, setDefaultPrefix, prefixPath, prefixExists, prefixDriveRoots, isPrefixRoot, healPrefix, MAIN }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue