Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

On upload also update the client state

Also some minor renaming (default_ocaml_version and default_opam_version are not default versions, they are fixed, so default is not necessary)
  • Loading branch information...
commit 86f0ddea2f5ec9da8b62b91ffb496aa92305fbe9 1 parent 3aa78b8
Thomas Gazagnaire samoht authored
29 src/client.ml
View
@@ -63,7 +63,7 @@ module Client : CLIENT = struct
else begin
File.Cudf.add t.home index_nv
(File.Cudf.cudf
- (Version Globals.default_opam_version)
+ (Version Globals.opam_version)
(match snd (RemoteServer.getOpam t.server (n, v)) with
| None -> assert false
| Some pkg -> pkg));
@@ -86,9 +86,9 @@ module Client : CLIENT = struct
log "init %s" (string_of_url url);
let config =
File.Config.config
- (Version Globals.default_opam_version)
+ (Version Globals.opam_version)
url
- (Version Globals.default_ocaml_version) in
+ (Version Globals.ocaml_version) in
let home = Path.init Globals.opam_path in
File.Config.add home (Path.config home) config;
update ()
@@ -352,17 +352,20 @@ module Client : CLIENT = struct
else
None in
match Path.find t.home filename with
- | Path.File binary -> Some (Tar_gz binary)
- | Path.Directory _ -> f "is a directory" (Path.raw_targz filename)
- | Path.Not_exists -> f "has not been found" Empty in
+ | Path.File binary -> Some (Tar_gz binary)
+ | Path.Directory _ -> f "is a directory" (Path.raw_targz filename)
+ | Path.Not_exists -> f "has not been found" Empty in
+ (* Upload the archive to the server *)
match o with
- | Some v ->
- RemoteServer.newArchive t.server
- (RemoteServer.getOpam t.server
- (Path.nv_of_extension Namespace.default_version (Path.basename filename))
- ) v
- | None -> ()
+ | Some v ->
+ let package = Path.nv_of_extension Namespace.default_version (Path.basename filename) in
+ let local_server = Server.init Globals.opam_path in
+ (* Upload the archive to the remote server *)
+ RemoteServer.newArchive t.server (RemoteServer.getOpam t.server package) v;
+ (* Copy the archive in the client state *)
+ Server.newArchive local_server (Server.getOpam local_server package) v
+ | None -> ()
type config_request = Dir
let config Dir name =
@@ -381,3 +384,5 @@ module Client : CLIENT = struct
Printf.printf "-I %s"
(match Path.ocaml_options_of_library t.home name with I s -> s)
end
+
+
4 src/file.ml
View
@@ -78,7 +78,7 @@ struct
log "read %s" (Path.string_of_filename f);
let aux contents =
let file = parse_colon contents in
- let version = try List.assoc "version" file with _ -> Globals.default_opam_version in
+ let version = try List.assoc "version" file with _ -> Globals.opam_version in
let sources =
try
let sources = List.assoc "sources" file in
@@ -152,7 +152,7 @@ struct
let cudf opam_version pkg = { opam_version ; package = { preamble = None ; pkg = [ pkg ] ; request = None } }
let empty =
- { opam_version = Version Globals.default_opam_version
+ { opam_version = Version Globals.opam_version
; package = { preamble = None ; pkg = [] ; request = None } }
let find t f =
4 src/globals.ml
View
@@ -5,8 +5,8 @@ let version = "0.1+dev"
let default_hostname = "opam.ocamlpro.com"
let default_port = 9999
-let default_ocaml_version = Sys.ocaml_version
-let default_opam_version = "1"
+let ocaml_version = Sys.ocaml_version
+let opam_version = "1"
let opam_server_path = ".opam-server"
let opam_path = ".opam"
2  src/ocp_get_server.ml
View
@@ -34,7 +34,7 @@ let _ = Arg.parse args (fun s -> Printf.eprintf "%s: Unknown\n" s) usage
let server fn =
let host = (gethostbyname(gethostname ())).h_addr_list.(0) in
let addr = ADDR_INET (host, !port) in
- let state = Server.init () in
+ let state = Server.init Globals.opam_server_path in
if !Globals.debug then
Printf.printf "Listening on port %d (%s) ...\n%!"
!port (string_of_inet_addr host);
2  src/path.ml
View
@@ -178,7 +178,7 @@ module Path : PATH = struct
let (///) = concat
let init s =
let home = home // s in
- { home ; home_ocamlversion = home // Globals.default_ocaml_version }
+ { home ; home_ocamlversion = home // Globals.ocaml_version }
let root = Raw "/"
let package _ s = Raw (Printf.sprintf "%s" s)
6 src/server.ml
View
@@ -47,11 +47,11 @@ module Server = struct
map) NV_map.empty
(Path.index_opam_list home)
- let init () =
- let home = Path.init Globals.opam_server_path in
+ let init path =
+ let home = Path.init path in
{ current_repository = read_index home
; home
- ; version_package_manager = Version Globals.default_opam_version }
+ ; version_package_manager = Version Globals.opam_version }
let getList t = BatList.map fst (NV_map.bindings t.current_repository)
let getOpam t n_v = n_v, NV_map.Exceptionless.find n_v t.current_repository
Please sign in to comment.
Something went wrong with that request. Please try again.