Jelajahi Sumber

Further improvements

downlaod enforcer currently broken
Daniel Gibbs 9 tahun lalu
induk
melakukan
a4f634dc03
1 mengubah file dengan 40 tambahan dan 29 penghapusan
  1. 40 29
      lgsm/functions/command_fastdl.sh

+ 40 - 29
lgsm/functions/command_fastdl.sh

@@ -40,28 +40,30 @@ fn_fastdl_config(){
 		echo "${fastdldir}"
 		echo ""
 		if fn_prompt_yn "Overwrite existing directory?" Y; then
-			clearoldfastdl="on"
+			fn_script_log_info "Overwrite existing directory: YES"
 		else
-			clearoldfastdl="off"
+			core_exit.sh
 		fi
 	fi
 
 	# Garry's Mod Specific
 	if [ "${gamename}" == "Garry's Mod" ]; then
 		# Prompt to clear addons dir from fastdl, can use unnecessary space or not be required depending on addon's file structures
-		fn_print_dots
 		if fn_prompt_yn "Clear addons directory from FastDL?" Y; then
 			cleargmodaddons="on";
+			fn_script_log_info "Clear addons directory from FastDL: YES"
 		else
 			cleargmodaddons="off";
+			fn_script_log_info "Clear addons directory from FastDL: NO"
 		fi
 
 		# Prompt for download enforcer, which is using a .lua addfile resource generator
-		fn_print_dots
 		if fn_prompt_yn "Use client download enforcer?" Y; then
 			luaressource="on"
+			fn_script_log_info "Use client download enforcer: YES"
 		else
 			luaressource="off"
+			fn_script_log_info "Use client download enforcer: NO"
 		fi
 	fi
 }
@@ -74,11 +76,11 @@ fn_fastdl_dirs(){
 		exitcode=$?
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
-			fn_script_log_fatal "creating web directory ${webdir}..."
+			fn_script_log_fatal "Creating web directory ${webdir}"
 			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_script_log_pass "creating web directory ${webdir}..."
+			fn_script_log_pass "Creating web directory ${webdir}"
 		fi
 		sleep 0.5
 	fi
@@ -88,11 +90,11 @@ fn_fastdl_dirs(){
 		exitcode=$?
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
-			fn_script_log_fatal "creating fastdl directory ${fastdldir}..."
+			fn_script_log_fatal "Creating fastdl directory ${fastdldir}"
 			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_script_log_pass "creating fastdl directory ${fastdldir}..."
+			fn_script_log_pass "Creating fastdl directory ${fastdldir}"
 		fi
 		sleep 0.5
 	fi
@@ -106,11 +108,11 @@ fn_clear_old_fastdl(){
 		exitcode=$?
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
-			fn_script_log_fatal "clearing existing FastDL directory ${fastdldir}..."
+			fn_script_log_fatal "Clearing existing FastDL directory ${fastdldir}"
 			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_script_log_pass "clearing existing FastDL directory ${fastdldir}..."
+			fn_script_log_pass "Clearing existing FastDL directory ${fastdldir}"
 		fi
 		sleep 0.5
 	fi
@@ -133,7 +135,6 @@ fn_fastdl_gmod(){
 		# Clear addons directory in fastdl
 		if [ "${cleargmodaddons}" == "on" ]; then
 			echo -en "clearing addons dir from fastdl dir"
-			fn_script_log "clearing addons dir from fastdl dir..."
 			sleep 1
 			rm -R "${fastdldir:?}/addons"
 			exitcode=$?
@@ -147,7 +148,6 @@ fn_fastdl_gmod(){
 			fi
 		fi
 	fi
-
 	# Correct content that may be into a lua directory by mistake like some darkrpmodification addons
 	if [ -d "${fastdldir}/lua" ]; then
 		echo -en "correcting DarkRP files..."
@@ -229,13 +229,13 @@ fn_fastdl_source(){
 		fn_fastdl_dirs
 
 		echo -e "copying files to ${fastdldir}"
-		fn_script_log "copying files to ${fastdldir}"
+		fn_script_log_info "Copying files to ${fastdldir}"
 	else
 		if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
 			rm -f "${tmpdir}/fastdl_files_to_compress.txt"
 		fi
-		echo -e "analyzing required files"
-		fn_script_log "analyzing required files"
+		echo -e "analysing required files"
+		fn_script_log_info "Analysing required files"
 	fi
 
 	local directorys_array=( "maps" "materials" "particles" "sounds" )
@@ -273,17 +273,26 @@ fn_fastdl_source(){
 				tput sc
 				if [ -z "${copyflag}" ]; then
 					tput rc; tput el
-					printf "gathering ${directory} ${allowed_extention} : ${fileswc}..."
+					printf "copying ${directory} ${allowed_extention} : ${fileswc}..."
 				fi
 				while read -r mapfile; do
 					((fileswc++))
 					if [ -n "${copyflag}" ]; then
 						tput rc; tput el
 						printf "copying ${directory} ${allowed_extention} : ${fileswc}..."
+						sleep 0.01
 						if [ ! -d "${fastdldir}/${directory}" ]; then
 							mkdir "${fastdldir}/${directory}"
 						fi
 						cp "${mapfile}" "${fastdldir}/${directory}"
+						exitcode=$?
+						if [ ${exitcode} -ne 0 ]; then
+							fn_print_fail_eol_nl
+							fn_script_log_fatal "Copying ${mapfile} > ${fastdldir}/${directory}"
+							core_exit.sh
+						else
+							fn_script_log_pass "Copying ${mapfile} > ${fastdldir}/${directory}"
+						fi
 					else
 						tput rc; tput el
 						printf "gathering ${directory} ${allowed_extention} : ${fileswc}..."
@@ -313,7 +322,8 @@ fn_fastdl_source(){
 	fi
 
 	if [ -z "${copyflag}" ]; then
-		echo "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0) "
+		echo "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)"
+		fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)"
 		rm "${tmpdir}/fastdl_files_to_compress.txt"
 		if fn_prompt_yn "Continue?" Y; then
 			copyflag=1
@@ -322,6 +332,9 @@ fn_fastdl_source(){
 			core_exit.sh
 		fi
 	else
+		if [ "${gamename}" == "Garry's Mod" ]; then
+			fn_fastdl_gmod_lua_enforcer
+		fi
 		fn_fastdl_bzip2
 	fi
 }
@@ -330,34 +343,33 @@ fn_fastdl_source(){
 fn_fastdl_gmod_lua_enforcer(){
 	# Remove lua file if luaressource is turned off and file exists
 	if [ -f "${luafastdlfullpath}" ]; then
-		echo -en "removing existing download enforcer..."
+		echo -en "removing existing download enforcer: ${luafastdlfile}..."
 		rm -R "${luafastdlfullpath:?}"
 		exitcode=$?
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
-			fn_script_log_fatal "removing existing download enforcer"
+			fn_script_log_fatal "removing existing download enforcer ${luafastdlfullpath}"
 			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_script_log_pass "removing existing download enforcer"
+			fn_script_log_pass "removing existing download enforcer ${luafastdlfullpath}"
 		fi
 	fi
 	# Remove old lua file and generate a new one if user said yes
 	if [ "${luaressource}" == "on" ]; then
-		echo -en "creating new download enforcer..."
-		fn_script_log "creating new download enforcer"
+		echo -en "creating new download enforcer: ${luafastdlfile}..."
 		# Read all filenames and put them into a lua file at the right path
-		find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do
+		find "${fastdldir:?}" \( -type f -name "*.bz2" \) -printf '%P\n' | while read line; do
 			echo "resource.AddFile( "\""${line}"\"" )" >> "${luafastdlfullpath}"
 		done
 		exitcode=$?
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
-			fn_script_log_fatal "creating new download enforcer"
+			fn_script_log_fatal "creating new download enforcer ${luafastdlfullpath}"
 			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_script_log_pass "creating new download enforcer"
+			fn_script_log_pass "creating new download enforcer ${luafastdlfullpath}"
 		fi
 	fi
 }
@@ -369,11 +381,11 @@ fn_fastdl_bzip2(){
 		exitcode=$?
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
-			fn_script_log_fatal "creating web directory ${webdir}..."
+			fn_script_log_fatal "compressing ${filetocompress}"
 			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_script_log_pass "creating web directory ${webdir}..."
+			fn_script_log_pass "compressing ${filetocompress}"
 		fi
 	done < <(find  "${fastdldir:?}" \( -type f ! -name "*.bz2" \))
 }
@@ -383,7 +395,7 @@ fn_fastdl_completed(){
 	echo "FastDL files are located in:"
 	echo "${webdir}"
 	echo "FastDL completed"
-	fn_script_log "FastDL completed"
+	fn_script_log_info "FastDL completed"
 }
 
 # Run functions
@@ -394,7 +406,6 @@ fn_fastdl_config
 fn_fastdl_source
 if [ "${gamename}" == "Garry's Mod" ]; then
 	fn_fastdl_gmod
-	fn_fastdl_gmod_lua_enforcer
 fi
 fn_fastdl_completed
 core_exit.sh