Changeset 23894 for trunk/ippTools/src/receivetool.c
- Timestamp:
- Apr 16, 2009, 5:54:55 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/receivetool.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/receivetool.c
r23885 r23894 95 95 96 96 // required 97 PXOPT_LOOKUP_STR(source, config->args, "-s tage", true, false);97 PXOPT_LOOKUP_STR(source, config->args, "-source", true, false); 98 98 PXOPT_LOOKUP_STR(product, config->args, "-product", true, false); 99 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 99 100 100 101 // optional 101 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);102 102 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 103 103 PXOPT_LOOKUP_STR(last, config->args, "-last", false, false); … … 168 168 169 169 // required 170 PXOPT_LOOKUP_S64(source_id, config->args, "-source_id", true, false); 171 PXOPT_LOOKUP_STR(fileset, config->args, "-fileset", true, false); 172 173 if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset)) { 170 PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false); 171 psMetadataItem *filesets = psMetadataLookup(config->args, "-fileset"); 172 if (!filesets) { 173 psError(PS_ERR_UNKNOWN, true, "-fileset is required"); 174 return false; 175 } 176 177 if (!psDBTransaction(config->dbh)) { 178 psError(PS_ERR_UNKNOWN, false, "Database error"); 179 return false; 180 } 181 182 psListIterator *iter = psListIteratorAlloc(filesets->data.list, PS_LIST_HEAD, false); // Iterator 183 psMetadataItem *item = NULL; // Item from iteration 184 while ((item = psListGetAndIncrement(iter))) { 185 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"); 189 if (!psDBTransaction(config->dbh)) { 190 psError(PS_ERR_UNKNOWN, false, "Database error"); 191 return false; 192 } 193 psFree(iter); 194 return false; 195 } 196 } 197 psFree(iter); 198 199 if (!psDBCommit(config->dbh)) { 174 200 psError(PS_ERR_UNKNOWN, false, "Database error"); 175 201 return false; … … 184 210 185 211 // required 186 PXOPT_LOOKUP_S64(source_id, config->args, "-s ource_id", true, false);212 PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false); 187 213 PXOPT_LOOKUP_STR(fileset, config->args, "-fileset", true, false); 188 214 … … 212 238 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 213 239 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 240 241 // optional 242 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 243 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 214 244 215 245 psString query = pxDataGet("receivetool_pendingfileset.sql"); … … 227 257 psFree(where); 228 258 259 if (limit) { 260 psString limitString = psDBGenerateLimitSQL(limit); 261 psStringAppend(&query, " %s", limitString); 262 psFree(limitString); 263 } 264 229 265 if (!p_psDBRunQueryF(config->dbh, query)) { 230 266 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 244 280 return true; 245 281 } 246 if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", true)) {282 if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", !simple)) { 247 283 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 248 284 psFree(output); … … 260 296 // required 261 297 PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false); 262 PXOPT_LOOKUP_STR(file, config->args, "-file", true, false); 263 264 if (!receiveFileInsert(config->dbh, 0, fileset_id, file)) { 298 psMetadataItem *files = psMetadataLookup(config->args, "-file"); 299 if (!files) { 300 psError(PS_ERR_UNKNOWN, true, "-file is required"); 301 return false; 302 } 303 304 if (!psDBTransaction(config->dbh)) { 305 psError(PS_ERR_UNKNOWN, false, "Database error"); 306 return false; 307 } 308 309 psListIterator *iter = psListIteratorAlloc(files->data.list, PS_LIST_HEAD, false); // Iterator 310 psMetadataItem *item = NULL; // Item from iteration 311 while ((item = psListGetAndIncrement(iter))) { 312 psAssert(item && item->data.V && item->type == PS_DATA_STRING, "Argument is bad"); 313 314 if (!receiveFileInsert(config->dbh, 0, fileset_id, item->data.str)) { 315 psError(PS_ERR_UNKNOWN, false, "Unable to add file"); 316 if (!psDBTransaction(config->dbh)) { 317 psError(PS_ERR_UNKNOWN, false, "Database error"); 318 return false; 319 } 320 psFree(iter); 321 return false; 322 } 323 } 324 psFree(iter); 325 326 if (!psDBCommit(config->dbh)) { 265 327 psError(PS_ERR_UNKNOWN, false, "Database error"); 266 328 return false; … … 282 344 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.file_id", "=="); 283 345 346 // optional 347 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 348 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 349 284 350 psString query = pxDataGet("receivetool_pendingfile.sql"); 285 351 if (!query) { … … 296 362 psFree(where); 297 363 364 if (limit) { 365 psString limitString = psDBGenerateLimitSQL(limit); 366 psStringAppend(&query, " %s", limitString); 367 psFree(limitString); 368 } 369 298 370 if (!p_psDBRunQueryF(config->dbh, query)) { 299 371 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 313 385 return true; 314 386 } 315 if (!ippdbPrintMetadatas(stdout, output, "receiveFile", true)) {387 if (!ippdbPrintMetadatas(stdout, output, "receiveFile", !simple)) { 316 388 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 317 389 psFree(output); … … 328 400 329 401 // required 330 PXOPT_LOOKUP_S64(file set_id, config->args, "-source_id", true, false);402 PXOPT_LOOKUP_S64(file_id, config->args, "-file_id", true, false); 331 403 332 404 // optional … … 335 407 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 336 408 337 if (!receiveResultInsert(config->dbh, file set_id, dtime_copy, dtime_extract, fault)) {409 if (!receiveResultInsert(config->dbh, file_id, dtime_copy, dtime_extract, fault)) { 338 410 psError(PS_ERR_UNKNOWN, false, "Database error"); 339 411 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
