X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=matitaB%2Fmatita%2Fmatitadaemon.ml;h=a07e7e16039489d962b2b318890d1fb21960e133;hb=83fa6fc1317f18af956b194b996afae10ec859a7;hp=61b2dc5479a311eddd69c2b7c831fdee11647b3f;hpb=6c146035564b39f54a3c919135f179cec349c284;p=helm.git diff --git a/matitaB/matita/matitadaemon.ml b/matitaB/matita/matitadaemon.ml index 61b2dc547..a07e7e160 100644 --- a/matitaB/matita/matitadaemon.ml +++ b/matitaB/matita/matitadaemon.ml @@ -351,6 +351,8 @@ let logout (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = cgi#out_channel#commit_work() ;; +exception File_already_exists;; + let save (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = let cgi = Netcgi1_compat.Netcgi_types.of_compat_activation cgi in let env = cgi#environment in @@ -363,7 +365,12 @@ let save (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = let locked = cgi#argument_value "locked" in let unlocked = cgi#argument_value "unlocked" in let filename = libdir uid ^ "/" ^ (cgi # argument_value "file") in + let force = bool_of_string (cgi#argument_value "force") in prerr_endline ("Matita will save the file for user " ^ uid); + + if ((not force) && (Sys.file_exists filename)) then + raise File_already_exists; + let oc = open_out filename in output_string oc (locked ^ unlocked); close_out oc; @@ -382,7 +389,9 @@ let save (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = (); cgi#out_channel#output_string "ok" with - | Not_found _ -> + | File_already_exists -> + cgi#out_channel#output_string "cancelled" + | Sys_error _ -> cgi # set_header ~status:`Internal_server_error ~cache:`No_cache