X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=matitaB%2Fmatita%2Fmatitadaemon.ml;h=a07e7e16039489d962b2b318890d1fb21960e133;hb=83fa6fc1317f18af956b194b996afae10ec859a7;hp=c21bed2e7c25129d7130633062123f02dc1b8e22;hpb=acf77bb24694158a57444c7f32da46ceac8b30c4;p=helm.git diff --git a/matitaB/matita/matitadaemon.ml b/matitaB/matita/matitadaemon.ml index c21bed2e7..a07e7e160 100644 --- a/matitaB/matita/matitadaemon.ml +++ b/matitaB/matita/matitadaemon.ml @@ -268,7 +268,10 @@ let register (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = let userpw = cgi#argument_value "password" in (try MatitaAuthentication.add_user uid userpw; - env#set_output_header_field "Location" "/index.html" +(* env#set_output_header_field "Location" "/index.html" *) + cgi#out_channel#output_string + ("" + ^ "Redirecting to login page...") with | MatitaAuthentication.UsernameCollision _ -> cgi#set_header @@ -305,7 +308,10 @@ let login (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = cgi#set_header ~set_cookies:[cookie] (); *) env#set_output_header_field "Set-Cookie" ("session=" ^ (Uuidm.to_string sid)); - env#set_output_header_field "Location" "/index.html" +(* env#set_output_header_field "Location" "/index.html" *) + cgi#out_channel#output_string + ("" + ^ "Redirecting to Matita page...") end else begin @@ -345,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 @@ -357,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; @@ -376,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