修复:Windows 更新检查仅探测程序路径,避免慢磁盘校验超时

This commit is contained in:
2026-11-05 14:40:33 +08:00
parent b208f93945
commit 4843768694
5 changed files with 278 additions and 1 deletions
+20
View File
@@ -83,6 +83,26 @@ class UpdateTests(unittest.TestCase):
self.assertEqual('2026.11.04', self.validate()['version'])
self.assertEqual(update.runtime_fingerprint(self.manifest), update.runtime_fingerprint(copy.deepcopy(self.manifest)))
def test_check_does_not_probe_fourteen_thousand_immutable_runtime_paths(self):
self.manifest['files'] += [{'path': f'runtimes/python/Lib/library-{i}.py', 'sha256': 'a' * 64}
for i in range(14000)]
update.atomic(self.root / 'manifest.json', self.manifest)
with patch.object(update, 'destination', wraps=update.destination) as probe:
self.validate()
names = [call.args[1] for call in probe.call_args_list]
self.assertFalse(any(name.startswith('runtimes/') for name in names))
self.assertLess(len(names), 100)
self.assertIn(update.KEY, names)
self.assertIn('app/web/obsolete.js', names)
def test_obsolete_program_symlink_is_still_rejected_before_replacement(self):
target = self.root / 'app/web/obsolete-link'
target.symlink_to(Path(self.temp.name), target_is_directory=True)
self.manifest['files'].append({'path': 'app/web/obsolete-link/file.js', 'sha256': 'a' * 64})
update.atomic(self.root / 'manifest.json', self.manifest)
with self.assertRaises(update.UpdateError):
self.validate()
def test_wrong_signature_key_and_modified_payload_are_rejected(self):
with self.assertRaises(update.UpdateError):
update.validate_release(self.envelope(private=Ed25519PrivateKey.generate()), self.root)