Changeset 23898 for trunk/ippTools/src/receivetool.c
- Timestamp:
- Apr 17, 2009, 10:12:18 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/receivetool.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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)) {
Note:
See TracChangeset
for help on using the changeset viewer.
