From d1b2c57c37bdc28182646946f8c0d68662abd070 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 21 Oct 2014 22:06:22 -0700 Subject: [PATCH] client, Android: clear out project directory on project reset. When a project is reset, the client deletes all the files from its dir that BOINC knows about. However, there may be other files, created by its apps. On Android, where space is likely to be scarce, delete these when the project is reset. Maybe we should do this on all projects. But we'd need to not to delete user-created files like app_config.xml, and anonymous-platform stuff like app_info.xml and the app files. --- client/client_state.cpp | 9 +++ sched/script_validator.cpp | 128 +++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 sched/script_validator.cpp diff --git a/client/client_state.cpp b/client/client_state.cpp index 76db980007..5245851e04 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -1958,6 +1958,15 @@ int CLIENT_STATE::reset_project(PROJECT* project, bool detaching) { } garbage_collect_always(); } +#ifdef ANDROID + // space is likely to be an issue on Android, so clean out project dir + // If we did this on other platforms we'd need to avoid deleting + // app_config.xml, but this isn't likely to exist on Android. + // + if (!project->anonymous_platform) { + client_clean_out_dir(project.project_dir(), "reset project"); + } +#endif // force refresh of scheduler URLs // diff --git a/sched/script_validator.cpp b/sched/script_validator.cpp new file mode 100644 index 0000000000..43b80dece8 --- /dev/null +++ b/sched/script_validator.cpp @@ -0,0 +1,128 @@ +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2014 University of California +// +// BOINC is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// BOINC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +// A validator that runs scripts to check and compare results +// cmdline args: +// --init_script scriptname +// --compare_script scriptname +// +// the init script is called as +// scriptname f1 ... fn +// where f1 ... fn are the output files of a job (there may be just one) +// It returns zero if the files are valid +// +// the compare script is called as +// scriptname f1 ... fn g1 ... gn +// where f1 ... fn are the output files of one job, +// and g1 ... gn are the output files are another job. +// It returns zero if the files are equivalent. + +#include + +#include "validate_util2.h" +#include "error_numbers.h" +#include "boinc_db.h" +#include "sched_util.h" +#include "validate_util.h" +#include "validator.h" + +using std::string; +using std::vector; + +bool first = true; +char init_script[MAXPATHLEN], compare_script[MAXPATHLEN]; + +void parse_cmdline() { + strcpy(init_script, ""); + strcpy(compare_script, ""); + for (int i=1; i paths; + int retval; + retval = get_output_file_paths(result, paths); + if (retval) { + fprintf(stderr, "get_output_file_paths() returned %d\n", retval); + return retval; + } + char cmd[4096]; + strcpy(cmd, init_script); + for (unsigned int i=0; i paths1, paths2; + int retval; + retval = get_output_file_paths(r1, paths1); + if (retval) { + fprintf(stderr, "get_output_file_paths() returned %d\n", retval); + return retval; + } + retval = get_output_file_paths(r2, paths2); + if (retval) { + fprintf(stderr, "get_output_file_paths() returned %d\n", retval); + return retval; + } + char cmd[4096]; + strcpy(cmd, compare_script); + for (unsigned int i=0; i