Remove unreachable code and ensure consistent escaping for both Debian and Alpine

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-22 14:53:59 +00:00
parent 6f7a54a614
commit f099bd8e05

View File

@ -280,9 +280,6 @@ export default class SystemService {
type: 'updateLinuxMirror', type: 'updateLinuxMirror',
message: 'Warning: Unable to detect current mirror. Please manually configure /etc/apt/sources.list', message: 'Warning: Unable to detect current mirror. Please manually configure /etc/apt/sources.list',
}); });
} else if (targetDomain) {
// Fallback: just update package lists
command = `apt-get update`;
} }
} catch (error) { } catch (error) {
this.logger.error('Failed to read /etc/apt/sources.list', error); this.logger.error('Failed to read /etc/apt/sources.list', error);
@ -307,7 +304,8 @@ export default class SystemService {
// Escape backslashes first, then other special characters // Escape backslashes first, then other special characters
command = `sed -i 's/${defaultDomain command = `sed -i 's/${defaultDomain
.replace(/\\/g, '\\\\') // Escape backslashes first .replace(/\\/g, '\\\\') // Escape backslashes first
.replace(/\//g, '\\/')}/${targetDomain .replace(/\//g, '\\/') // Escape forward slashes
.replace(/\./g, '\\.')}/${targetDomain
.replace(/\\/g, '\\\\') // Escape backslashes first .replace(/\\/g, '\\\\') // Escape backslashes first
.replace(/\//g, '\\/')}/g' /etc/apk/repositories && apk update -f`; .replace(/\//g, '\\/')}/g' /etc/apk/repositories && apk update -f`;
} catch (error) { } catch (error) {