Indefero

Indefero Commit Details


Date:2011-06-03 18:03:30 (13 years 6 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:8ff15368ce28c2f7a366a7326f9183d180918b0a
Parents: 32cde534bd18d914841b7ee914969fb898206f68
Message:Improve error handling and reporting (partially resolves issue 695)

Changes:

File differences

src/IDF/Plugin/SyncMonotone.php
132132
133133
134134
135
135
136136
137137
138138
......
141141
142142
143143
144
144
145145
146146
147147
148
148
149
150
149151
150
152
153
151154
152155
153156
......
182185
183186
184187
185
188
189
190
186191
187
192
193
188194
189195
190196
......
238244
239245
240246
241
247
248
249
242250
243
251
252
244253
245254
246255
247256
248257
249258
250
259
260
261
251262
252
263
264
253265
254266
255267
......
264276
265277
266278
267
279
280
281
268282
269
283
284
270285
271286
272287
......
315330
316331
317332
318
333
334
335
319336
320
337
338
321339
322340
323341
......
361379
362380
363381
364
382
383
384
365385
366
386
387
367388
368389
369390
......
384405
385406
386407
387
408
409
410
388411
389
412
413
390414
391415
392416
......
401425
402426
403427
404
428
429
430
405431
406
432
407433
408434
409435
410436
411437
412
438
413439
414
440
415441
416442
417443
......
473499
474500
475501
502
503
476504
477
505
506
478507
479508
480509
......
505534
506535
507536
508
537
538
539
509540
510
541
542
511543
512544
513545
......
598630
599631
600632
601
633
602634
635
636
603637
604
638
639
605640
606641
607642
......
611646
612647
613648
614
649
615650
651
652
616653
617
618
654
655
619656
620657
621658
......
693730
694731
695732
696
733
697734
735
736
698737
699
738
739
700740
701741
702742
......
711751
712752
713753
714
715
754
755
756
757
716758
717
718
759
760
719761
720762
721763
......
823865
824866
825867
826
868
827869
828870
829871
foreach ($confdir_contents as $content) {
if (!file_exists($confdir.$content)) {
throw new IDF_Scm_Exception(sprintf(
__('The configuration file %s is missing.'), $content
__('The configuration file "%s" is missing.'), $content
));
}
}
$projectpath = sprintf($projecttempl, $shortname);
if (file_exists($projectpath)) {
throw new IDF_Scm_Exception(sprintf(
__('The project path %s already exists.'), $projectpath
__('The project path "%s" already exists.'), $projectpath
));
}
if (!mkdir($projectpath)) {
if (!@mkdir($projectpath)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('The project path %s could not be created.'), $projectpath
__('The project path "%s" could not be created: %s'),
$projectpath, $err
));
}
//
$keydir = Pluf::f('tmp_folder').'/mtn-client-keys';
if (!file_exists($keydir)) {
if (!mkdir($keydir)) {
if (!@mkdir($keydir)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('The key directory %s could not be created.'), $keydir
__('The key directory "%s" could not be created: %s'),
$keydir, $err
));
}
}
foreach ($confdir_contents as $content) {
$filepath = $projectpath.'/'.$content;
if (substr($content, -1) == '/') {
if (!mkdir($filepath)) {
if (!@mkdir($filepath)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not create configuration directory "%s"'), $filepath
__('Could not create configuration directory "%s": %s'),
$filepath, $err
));
}
continue;
}
if (substr($content, -3) != '.in') {
if (!symlink($confdir.$content, $filepath)) {
if (!@symlink($confdir.$content, $filepath)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
IDF_Scm_Exception(sprintf(
__('Could not create symlink "%s"'), $filepath
__('Could not create symlink for configuration file "%s": %s'),
$filepath, $err
));
}
continue;
// remove the .in
$filepath = substr($filepath, 0, -3);
if (file_put_contents($filepath, $filecontents, LOCK_EX) === false) {
if (@file_put_contents($filepath, $filecontents, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write configuration file "%s"'), $filepath
__('Could not write configuration file "%s": %s'),
$filepath, $err
));
}
}
// FIXME: more sanity - what happens on failing writes? we do not
// have a backup copy of usher.conf around...
if (file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
if (@file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write usher configuration file "%s"'), $usher_config
__('Could not write usher configuration file "%s": %s'),
$usher_config, $err
));
}
$write_permissions = implode("\n", $key_ids);
$rcfile = $projectpath.'/write-permissions';
if (file_put_contents($rcfile, $write_permissions, LOCK_EX) === false) {
if (@file_put_contents($rcfile, $write_permissions, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write write-permissions file "%s"'), $rcfile
__('Could not write write-permissions file "%s": %s'),
$rcfile, $err
));
}
}
$read_permissions = IDF_Scm_Monotone_BasicIO::compile(array($stanza));
$rcfile = $projectpath.'/read-permissions';
if (file_put_contents($rcfile, $read_permissions, LOCK_EX) === false) {
if (@file_put_contents($rcfile, $read_permissions, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write read-permissions file "%s"'), $rcfile
__('Could not write read-permissions file "%s": %s'),
$rcfile, $err
));
}
$serverRestartRequired = false;
if ($project->private && file_exists($projectfile) && is_link($projectfile)) {
if (!unlink($projectfile)) {
if (!@unlink($projectfile)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
IDF_Scm_Exception(sprintf(
__('Could not remove symlink "%s"'), $projectfile
__('Could not remove symlink "%s": %s'), $projectfile, $err
));
}
$serverRestartRequired = true;
} else
if (!$project->private && !file_exists($projectfile)) {
if (!symlink($templatefile, $projectfile)) {
if (!@symlink($templatefile, $projectfile)) {
throw new IDF_Scm_Exception(sprintf(
__('Could not create symlink "%s"'), $projectfile
__('Could not create symlink "%s": %s'), $projectfile, $err
));
}
$serverRestartRequired = true;
if ($keyname && $keyhash &&
file_exists($keydir .'/'. $keyname . '.' . $keyhash)) {
if (!@unlink($keydir .'/'. $keyname . '.' . $keyhash)) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not delete client private key %s'), $keyname
__('Could not delete client private key "%s": %s'),
$keyname, $err
));
}
}
// FIXME: more sanity - what happens on failing writes? we do not
// have a backup copy of usher.conf around...
if (file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
if (@file_put_contents($usher_config, $usher_rc, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write usher configuration file "%s"'), $usher_config
__('Could not write usher configuration file "%s": %s'),
$usher_config, $err
));
}
$read_perms = IDF_Scm_Monotone_BasicIO::compile($parsed_read_perms);
if (file_put_contents($projectpath.'/read-permissions',
if (@file_put_contents($projectpath.'/read-permissions',
$read_perms, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write read-permissions for project "%s"'), $shortname
__('Could not write read-permissions for project "%s": %s'),
$shortname, $err
));
}
}
if (!in_array('*', $lines) && !in_array($mtn_key_id, $lines)) {
$lines[] = $mtn_key_id;
}
if (file_put_contents($projectpath.'/write-permissions',
if (@file_put_contents($projectpath.'/write-permissions',
implode("\n", $lines) . "\n", LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write write-permissions file for project "%s"'),
$shortname
__('Could not write write-permissions file for project "%s": %s'),
$shortname, $err
));
}
$read_perms = IDF_Scm_Monotone_BasicIO::compile($parsed_read_perms);
if (file_put_contents($projectpath.'/read-permissions',
if (@file_put_contents($projectpath.'/read-permissions',
$read_perms, LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write read-permissions for project "%s"'), $shortname
__('Could not write read-permissions for project "%s": %s'),
$shortname, $err
));
}
}
continue;
}
}
if (file_put_contents($projectpath.'/write-permissions',
implode("\n", $lines) . "\n", LOCK_EX) === false) {
if (@file_put_contents($projectpath.'/write-permissions',
implode("\n", $lines) . "\n", LOCK_EX) === false) {
$err = error_get_last();
$err = $err == null ? 'unknown error' : $err['message'];
throw new IDF_Scm_Exception(sprintf(
__('Could not write write-permissions file for project "%s"'),
$shortname
__('Could not write write-permissions file for project "%s": %s'),
$shortname, $err
));
}
foreach ($scan as $subpath) {
$status |= self::_delete_recursive($subpath);
}
$status |= rmdir($path);
$status |= @rmdir($path);
return $status;
}
}

Archive Download the corresponding diff file

Page rendered in 0.08228s using 14 queries.