MCPcopy Create free account
hub / github.com/WavesMan/Disable-automatic-Windows-update / enable

Method enable

python/core/services.py:177–199  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

175 return Result(False, error={"code": "REGISTRY_WRITE_FAILED", "message": "部分键写入失败", "details": errors})
176
177 def enable(self) -> Result:
178 start = time.perf_counter()
179 log_event(logging.INFO, "onedrive_enable_started", "开始启用 OneDrive", action="enable_onedrive", status="started")
180 cmds = [
181 f'reg add "{ONEDRIVE}" /v "DisableFileSyncNGSC" /t REG_DWORD /d 0 /f',
182 f'reg add "{ONEDRIVE_WIN_POLICY}" /v "DisableFileSync" /t REG_DWORD /d 0 /f',
183 ]
184 ok, errors = self.registry.batch(cmds)
185 duration_ms = int((time.perf_counter() - start) * 1000)
186 if ok:
187 log_event(logging.INFO, "onedrive_enable_finished", "启用 OneDrive 成功", action="enable_onedrive", status="ok", duration_ms=duration_ms)
188 return Result(True, data={"status": "enabled"})
189 log_event(
190 logging.ERROR,
191 "onedrive_enable_finished",
192 "启用 OneDrive 失败",
193 action="enable_onedrive",
194 status="failed",
195 duration_ms=duration_ms,
196 error_type="REGISTRY_WRITE_FAILED",
197 error_message="; ".join(errors),
198 )
199 return Result(False, error={"code": "REGISTRY_WRITE_FAILED", "message": "部分键写入失败", "details": errors})
200
201
202class VersionService:

Callers

nothing calls this directly

Calls 3

log_eventFunction · 0.85
ResultClass · 0.85
batchMethod · 0.80

Tested by

no test coverage detected