122 Entry(session_name, args.theory_name, args.name, |
122 Entry(session_name, args.theory_name, args.name, |
123 if (args.compress) Future.fork(body.maybe_compress(cache = cache)) |
123 if (args.compress) Future.fork(body.maybe_compress(cache = cache)) |
124 else Future.value((false, body))) |
124 else Future.value((false, body))) |
125 } |
125 } |
126 |
126 |
127 def read_entry(db: SQL.Database, session_name: String, theory_name: String, name: String): Entry = |
127 def read_entry(db: SQL.Database, session_name: String, theory_name: String, name: String) |
|
128 : Option[Entry] = |
128 { |
129 { |
129 val select = |
130 val select = |
130 Data.table.select(List(Data.compressed, Data.body), |
131 Data.table.select(List(Data.compressed, Data.body), |
131 Data.where_equal(session_name, theory_name, name)) |
132 Data.where_equal(session_name, theory_name, name)) |
132 db.using_statement(select)(stmt => |
133 db.using_statement(select)(stmt => |
133 { |
134 { |
134 val res = stmt.execute_query() |
135 val res = stmt.execute_query() |
135 if (res.next()) { |
136 if (res.next()) { |
136 val compressed = res.bool(Data.compressed) |
137 val compressed = res.bool(Data.compressed) |
137 val body = res.bytes(Data.body) |
138 val body = res.bytes(Data.body) |
138 Entry(session_name, theory_name, name, Future.value(compressed, body)) |
139 Some(Entry(session_name, theory_name, name, Future.value(compressed, body))) |
139 } |
140 } |
140 else error(message("Bad export", theory_name, name)) |
141 else None |
141 }) |
142 }) |
142 } |
143 } |
143 |
144 |
144 |
145 |
145 /* database consumer thread */ |
146 /* database consumer thread */ |
272 // export |
273 // export |
273 if (export_pattern != "") { |
274 if (export_pattern != "") { |
274 val xz_cache = XZ.make_cache() |
275 val xz_cache = XZ.make_cache() |
275 |
276 |
276 val matcher = make_matcher(export_pattern) |
277 val matcher = make_matcher(export_pattern) |
277 for { (theory_name, name) <- export_names if matcher(theory_name, name) } |
278 for { |
278 { |
279 (theory_name, name) <- export_names if matcher(theory_name, name) |
279 val entry = read_entry(db, session_name, theory_name, name) |
280 entry <- read_entry(db, session_name, theory_name, name) |
|
281 } { |
280 val path = export_dir + Path.basic(theory_name) + Path.explode(name) |
282 val path = export_dir + Path.basic(theory_name) + Path.explode(name) |
281 |
|
282 progress.echo("exporting " + path) |
283 progress.echo("exporting " + path) |
283 Isabelle_System.mkdirs(path.dir) |
284 Isabelle_System.mkdirs(path.dir) |
284 Bytes.write(path, entry.uncompressed(cache = xz_cache)) |
285 Bytes.write(path, entry.uncompressed(cache = xz_cache)) |
285 } |
286 } |
286 } |
287 } |