X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2FmatitaSync.ml;h=e12c1cd146c11506322c8c19514c8d6e1bb9209e;hb=91a095f0686ee569ba035e4e30c7d071588cb8e7;hp=51007df29ea5a64a74986770a754bda14bb269b5;hpb=d35d134356645a09eb72db6e484f3df583123af1;p=helm.git diff --git a/helm/matita/matitaSync.ml b/helm/matita/matitaSync.ml index 51007df29..e12c1cd14 100644 --- a/helm/matita/matitaSync.ml +++ b/helm/matita/matitaSync.ml @@ -155,13 +155,25 @@ let add_obj uri obj status = if CicEnvironment.in_library uri then command_error (sprintf "%s already defined" suri) else begin - CicTypeChecker.typecheck_obj uri obj; - MetadataDb.index_obj ~dbd ~uri; (* must be in the env *) - let new_stuff = save_object_to_disk status uri obj in - MatitaLog.message (sprintf "%s defined" suri); - let status = add_aliases_for_object status suri obj in - { status with objects = new_stuff @ status.objects; - proof_status = No_proof } + CicTypeChecker.typecheck_obj uri obj; (* 1 *) + try + MetadataDb.index_obj ~dbd ~uri; (* 2 must be in the env *) + try + let new_stuff = save_object_to_disk status uri obj in (* 3 *) + try + MatitaLog.message (sprintf "%s defined" suri); + let status = add_aliases_for_object status suri obj in + { status with objects = new_stuff @ status.objects; + proof_status = No_proof } + with exc -> + List.iter MatitaMisc.safe_remove (List.map snd new_stuff); (* -3 *) + raise exc + with exc -> + ignore(MatitaDb.remove_uri uri); (* -2 *) + raise exc + with exc -> + CicEnvironment.remove_obj uri; (* -1 *) + raise exc end module OrderedUri =