Changeset 23898
- Timestamp:
- Apr 17, 2009, 10:12:18 AM (17 years ago)
- Location:
- trunk/ippTools
- Files:
-
- 1 added
- 3 edited
-
share/Makefile.am (modified) (1 diff)
-
share/receivetool_addfileset.sql (added)
-
src/receivetool.c (modified) (5 diffs)
-
src/receivetoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/share/Makefile.am
r23891 r23898 171 171 pztool_revertcopied.sql \ 172 172 receivetool_list.sql \ 173 receivetool_addfileset.sql \ 173 174 receivetool_pendingfileset.sql \ 174 175 receivetool_pendingfile.sql \ -
trunk/ippTools/src/receivetool.c
r23894 r23898 122 122 PXOPT_COPY_S64(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 123 123 124 // optional 125 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 126 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 127 124 128 psString query = pxDataGet("receivetool_list.sql"); 125 129 if (!query) { … … 136 140 psFree(where); 137 141 142 if (limit) { 143 psString limitString = psDBGenerateLimitSQL(limit); 144 psStringAppend(&query, " %s", limitString); 145 psFree(limitString); 146 } 147 138 148 if (!p_psDBRunQueryF(config->dbh, query)) { 139 149 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 153 163 return true; 154 164 } 155 if (!ippdbPrintMetadatas(stdout, output, "receiveSource", true)) {165 if (!ippdbPrintMetadatas(stdout, output, "receiveSource", !simple)) { 156 166 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 157 167 psFree(output); … … 175 185 } 176 186 187 psString query = pxDataGet("receivetool_addfileset.sql"); 188 if (!query) { 189 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); 190 return false; 191 } 192 177 193 if (!psDBTransaction(config->dbh)) { 178 194 psError(PS_ERR_UNKNOWN, false, "Database error"); 179 195 return false; 180 196 } 197 198 psString source_id_str = NULL; // source_id as a string 199 psStringAppend(&source_id_str, "%" PRId64, source_id); 181 200 182 201 psListIterator *iter = psListIteratorAlloc(filesets->data.list, PS_LIST_HEAD, false); // Iterator … … 184 203 while ((item = psListGetAndIncrement(iter))) { 185 204 psAssert(item && item->data.V && item->type == PS_DATA_STRING, "Argument is bad"); 186 187 if (!receiveFilesetInsert(config->dbh, 0, source_id, item->data.str)) { 188 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 205 const char *fileset = item->data.str; // Fileset name 206 207 if (!p_psDBRunQueryF(config->dbh, query, source_id_str, fileset)) { 208 psError(PS_ERR_UNKNOWN, false, "Database error"); 209 psFree(source_id_str); 210 psFree(query); 211 psFree(iter); 189 212 if (!psDBTransaction(config->dbh)) { 190 213 psError(PS_ERR_UNKNOWN, false, "Database error"); 191 return false;192 214 } 215 return false; 216 } 217 218 psArray *output = p_psDBFetchResult(config->dbh); // Output of query 219 if (!output) { 220 psError(PS_ERR_UNKNOWN, false, "Database error"); 221 psFree(source_id_str); 222 psFree(query); 193 223 psFree(iter); 194 224 return false; 195 225 } 226 if (psArrayLength(output) > 0) { 227 psTrace("receivetool", PS_LOG_INFO, "Fileset %s is already present", fileset); 228 psFree(output); 229 continue; 230 } 231 psFree(output); 232 233 if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset)) { 234 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 235 psFree(source_id_str); 236 psFree(query); 237 psFree(iter); 238 if (!psDBTransaction(config->dbh)) { 239 psError(PS_ERR_UNKNOWN, false, "Database error"); 240 } 241 return false; 242 } 196 243 } 197 244 psFree(iter); 245 psFree(query); 246 psFree(source_id_str); 198 247 199 248 if (!psDBCommit(config->dbh)) { -
trunk/ippTools/src/receivetoolConfig.c
r23894 r23898 56 56 psMetadataAddStr(listArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL); 57 57 psMetadataAddStr(listArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL); 58 psMetadataAddU64(listArgs, PS_LIST_TAIL, "-limit", 0, "limit result set", 0); 59 psMetadataAddBool(listArgs, PS_LIST_TAIL, "-simple", 0, "use simple output format?", false); 58 60 59 61 // -addfileset
Note:
See TracChangeset
for help on using the changeset viewer.
