changeset 1408:5b8f76e26ab7

remove old backups
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 24 Sep 2019 15:02:33 -0600
parents 1979cff9aad2
children 9103a61e64bc
files conv.txt src/luan/host/Backup.luan src/luan/host/main.luan src/luan/modules/Rpc.luan src/luan/modules/Thread.luan src/luan/modules/ThreadLuan.java src/luan/modules/host/Hosting.luan src/luan/modules/lucene/Lucene.luan
diffstat 8 files changed, 7 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
diff -r 1979cff9aad2 -r 5b8f76e26ab7 conv.txt
--- a/conv.txt	Fri Sep 20 17:00:30 2019 -0600
+++ b/conv.txt	Tue Sep 24 15:02:33 2019 -0600
@@ -1,3 +1,10 @@
+Lucene.recover
+schedule_backups_to
+Backup.luan
+backup_read_lock
+backup_write_lock
+backupLock
+
 Sql.luan query
 
 luan.lib
diff -r 1979cff9aad2 -r 5b8f76e26ab7 src/luan/host/Backup.luan
--- a/src/luan/host/Backup.luan	Fri Sep 20 17:00:30 2019 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-local Luan = require "luan:Luan.luan"
-local error = Luan.error
-local ipairs = Luan.ipairs or error()
-local Io = require "luan:Io.luan"
-local uri = Io.uri or error()
-local Thread = require "luan:Thread.luan"
-local run_in_lock = Thread.run_in_lock or error()
-local backup_write_lock = Thread.backup_write_lock or error()
-
-
-local Backup = {}
-
-local function backup_nonlocal(from,to)
-	to.mkdir()
-	for _, from_child in ipairs(from.children()) do
-		local name = from_child.name()
-		local to_child = to.child(name)
-		if from_child.is_directory() then
-			if name ~= "local" then
-				backup_nonlocal( from_child, to_child )
-			end
-		elseif from_child.is_file() then
-			to_child.link_to(from_child)
-		else
-			error(from_child.to_string().." isn't dir or file")
-		end
-	end
-end
-
-local function backup_all(from,to)
-	to.mkdir()
-	for _, from_child in ipairs(from.children()) do
-		local name = from_child.name()
-		local to_child = to.child(name)
-		if from_child.is_directory() then
-			backup_all( from_child, to_child )
-		elseif from_child.is_file() then
-			to_child.link_to(from_child)
-		else
-			error(from_child.to_string().." isn't dir or file")
-		end
-	end
-end
-
-local function backup_local(from,to)
-	local dir = "site/private/local/"
-	from = from.child(dir.."backup")
-	to = to.child(dir.."restore")
-	if from.exists() then
-		from.is_directory() or error(from.to_string().." isn't dir")
-		backup_all(from,to)
-	end
-end
-
-local function backup(backup_dir)
-	local sites_dir = uri "file:sites"
-	backup_dir.mkdir()
-	for _, site_dir in ipairs(sites_dir.children()) do
-		local to = backup_dir.child(site_dir.name())
-		backup_nonlocal( site_dir, to )
-		backup_local( site_dir, to )
-	end
-end
-
-function Backup.backup(backup_dir)
-	run_in_lock( backup_write_lock, backup, backup_dir )
-end
-
-return Backup
diff -r 1979cff9aad2 -r 5b8f76e26ab7 src/luan/host/main.luan
--- a/src/luan/host/main.luan	Fri Sep 20 17:00:30 2019 -0600
+++ b/src/luan/host/main.luan	Tue Sep 24 15:02:33 2019 -0600
@@ -122,7 +122,6 @@
 	site_dir or error "domain not found"
 	local file = Io.schemes.file(dir).child(name)
 	security(site_dir,file)
-	file.delete()
 	file.write(content)
 end
 
diff -r 1979cff9aad2 -r 5b8f76e26ab7 src/luan/modules/Rpc.luan
--- a/src/luan/modules/Rpc.luan	Fri Sep 20 17:00:30 2019 -0600
+++ b/src/luan/modules/Rpc.luan	Tue Sep 24 15:02:33 2019 -0600
@@ -144,14 +144,6 @@
 			server.close()
 			return
 		end_if
-		if cmd == "in_backup_read_lock" then
-			ThreadLuan.lock(Thread.backup_read_lock)
-			function responder.after_close()
-				Thread.backup_read_lock.unlock()
-			end
-			server.write(RpcResult.new())
-			return
-		end_if
 		local fn = fns[cmd]
 		if fn == nil then
 			server.write(JavaRpc.COMMAND_NOT_FOUND)
diff -r 1979cff9aad2 -r 5b8f76e26ab7 src/luan/modules/Thread.luan
--- a/src/luan/modules/Thread.luan	Fri Sep 20 17:00:30 2019 -0600
+++ b/src/luan/modules/Thread.luan	Tue Sep 24 15:02:33 2019 -0600
@@ -85,9 +85,6 @@
 
 local run_in_lock = ThreadLuan.runInLock
 Thread.run_in_lock = run_in_lock
-Thread.backup_read_lock = ThreadLuan.backupLock.readLock()
-Thread.backup_write_lock = ThreadLuan.backupLock.writeLock()
-
 
 function Thread.new_synchronizer()
 	local lock = ReentrantLock.new()
diff -r 1979cff9aad2 -r 5b8f76e26ab7 src/luan/modules/ThreadLuan.java
--- a/src/luan/modules/ThreadLuan.java	Fri Sep 20 17:00:30 2019 -0600
+++ b/src/luan/modules/ThreadLuan.java	Tue Sep 24 15:02:33 2019 -0600
@@ -243,8 +243,6 @@
 	}
 
 
-	public static final ReadWriteLock backupLock = new ReentrantReadWriteLock();
-
 	public static void lock(Lock lock)
 		throws LuanException, InterruptedException
 	{
diff -r 1979cff9aad2 -r 5b8f76e26ab7 src/luan/modules/host/Hosting.luan
--- a/src/luan/modules/host/Hosting.luan	Fri Sep 20 17:00:30 2019 -0600
+++ b/src/luan/modules/host/Hosting.luan	Tue Sep 24 15:02:33 2019 -0600
@@ -23,7 +23,6 @@
 	my_dir.is_directory() or error("'"..dir.."' is not a directory")
 	local host = Rpc.remote(domain)
 	local tree = host.get(domain,password)
-	host.in_backup_read_lock()
 	if tree == nil then
 		print("creating "..domain)
 		tree = host.create(domain,password)
@@ -67,7 +66,6 @@
 
 function Hosting.delete(domain,password)
 	local host = Rpc.remote(domain)
-	host.in_backup_read_lock()
 	host.delete(domain,password)
 	host.close()
 end
@@ -81,7 +79,6 @@
 
 function Hosting.change_domain(old_domain,new_domain,password)
 	local host = Rpc.remote(new_domain)
-	host.in_backup_read_lock()
 	local rtn = host.change_domain(old_domain,new_domain,password)
 	host.close()
 	return rtn
@@ -89,7 +86,6 @@
 
 function Hosting.change_password(domain,old_password,new_password)
 	local host = Rpc.remote(domain)
-	host.in_backup_read_lock()
 	local rtn = host.change_password(domain,old_password,new_password)
 	host.close()
 	return rtn
diff -r 1979cff9aad2 -r 5b8f76e26ab7 src/luan/modules/lucene/Lucene.luan
--- a/src/luan/modules/lucene/Lucene.luan	Fri Sep 20 17:00:30 2019 -0600
+++ b/src/luan/modules/lucene/Lucene.luan	Tue Sep 24 15:02:33 2019 -0600
@@ -13,7 +13,6 @@
 local Thread = require "luan:Thread.luan"
 local schedule = Thread.schedule or error()
 local run_in_lock = Thread.run_in_lock or error()
-local backup_read_lock = Thread.backup_read_lock or error()
 local Time = require "luan:Time.luan"
 local Rpc = require "luan:Rpc.luan"
 local LuceneIndex = require "java:luan.modules.lucene.LuceneIndex"
@@ -151,19 +150,6 @@
 		end )
 	end
 
-	function index.schedule_backups_to(backup_dir,repeating_delay)
-		local lucene_dir = index.dir
-		local function backup()
-			if backup_dir.last_modified() < lucene_dir.last_modified() then
-				run_in_lock(backup_read_lock, index.backup_to,backup_dir)
-				logger.info "backup"
-			end
-		end
-		schedule( backup, {
-			repeating_delay = repeating_delay or Time.period{minutes=10}
-		} )
-	end
-
 	function index.zip(zip_file)
 		index.snapshot( function(dir_path,file_names)
 			zip_file.delete()
@@ -220,14 +206,4 @@
 	return index
 end
 
-function Lucene.recover(index_dir,restore_dir)
-	if not index_dir.exists() and restore_dir.exists() then
-		index_dir.mkdir()
-		for _, child in ipairs(restore_dir.children()) do
-			index_dir.child(child.name()).link_to(child)
-		end
-		logger.error "recovered"
-	end
-end
-
 return Lucene