Fossil SCM
Added timestamp output to /json/dir when -checkin option is provided.
Commit
a81b34b8f5abd138fd57b5967643ba7e274ab430
Parent
c78773b2fdbdc7b…
1 file changed
+44
-35
+44
-35
| --- src/json_dir.c | ||
| +++ src/json_dir.c | ||
| @@ -51,14 +51,16 @@ | ||
| 51 | 51 | */ |
| 52 | 52 | static cson_value * json_page_dir_list(){ |
| 53 | 53 | cson_object * zPayload = NULL; |
| 54 | 54 | cson_array * zEntries = NULL; |
| 55 | 55 | cson_object * zEntry = NULL; |
| 56 | + cson_array * keyStore = NULL; | |
| 56 | 57 | cson_string * zKeyName = NULL; |
| 57 | 58 | cson_string * zKeySize = NULL; |
| 58 | 59 | cson_string * zKeyIsDir = NULL; |
| 59 | 60 | cson_string * zKeyUuid = NULL; |
| 61 | + cson_string * zKeyTime = NULL; | |
| 60 | 62 | char * zD = NULL; |
| 61 | 63 | char const * zDX = NULL; |
| 62 | 64 | int nD; |
| 63 | 65 | char * zUuid = NULL; |
| 64 | 66 | char const * zCI = NULL; |
| @@ -106,11 +108,11 @@ | ||
| 106 | 108 | ** Subdirectory names begin with "/". This causes them to sort |
| 107 | 109 | ** first and it also gives us an easy way to distinguish files |
| 108 | 110 | ** from directories in the loop that follows. |
| 109 | 111 | */ |
| 110 | 112 | db_multi_exec( |
| 111 | - "CREATE TEMP TABLE localfiles(n UNIQUE NOT NULL %s, u, sz, mtime DEFAULT NULL);", | |
| 113 | + "CREATE TEMP TABLE json_dir_files(n UNIQUE NOT NULL %s, u, sz, mtime DEFAULT NULL);", | |
| 112 | 114 | filename_collation() |
| 113 | 115 | ); |
| 114 | 116 | |
| 115 | 117 | if( zCI ){ |
| 116 | 118 | Stmt ins; |
| @@ -118,17 +120,27 @@ | ||
| 118 | 120 | ManifestFile *pPrev = 0; |
| 119 | 121 | int nPrev = 0; |
| 120 | 122 | int c; |
| 121 | 123 | |
| 122 | 124 | db_prepare(&ins, |
| 123 | - "INSERT OR IGNORE INTO localfiles VALUES(" | |
| 124 | - /*0*/ "pathelement(:x,0)," | |
| 125 | - /*1*/ ":u, " | |
| 126 | - /*2*/ "(SELECT size from blob where uuid=:s), " | |
| 127 | - /*3: TODO: mtime*/" NULL" | |
| 128 | - ")" | |
| 129 | - ); | |
| 125 | + "INSERT OR IGNORE INTO json_dir_files (n,u,sz,mtime) " | |
| 126 | + "SELECT" | |
| 127 | + " pathelement(:path,0)," | |
| 128 | + " a.uuid," | |
| 129 | + " a.size," | |
| 130 | + " CAST(strftime('%%s',e.mtime) AS INTEGER) " | |
| 131 | + "FROM" | |
| 132 | + " mlink m, " | |
| 133 | + " event e," | |
| 134 | + " blob a," | |
| 135 | + " blob b " | |
| 136 | + "WHERE" | |
| 137 | + " e.objid=m.mid" | |
| 138 | + " AND a.rid=m.fid"/*FILE artifact*/ | |
| 139 | + " AND b.rid=m.mid"/*CHECKIN artifact*/ | |
| 140 | + " AND a.uuid=:uuid" | |
| 141 | + ); | |
| 130 | 142 | manifest_file_rewind(pM); |
| 131 | 143 | while( (pFile = manifest_file_next(pM,0))!=0 ){ |
| 132 | 144 | if( nD>0 |
| 133 | 145 | && ((pFile->zName[nD-1]!='/') || (0!=memcmp(pFile->zName, zD, nD-1))) |
| 134 | 146 | ){ |
| @@ -139,14 +151,12 @@ | ||
| 139 | 151 | && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0 |
| 140 | 152 | && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/') |
| 141 | 153 | ){ |
| 142 | 154 | continue; |
| 143 | 155 | } |
| 144 | - db_bind_text(&ins, ":x", &pFile->zName[nD]); | |
| 145 | - db_bind_text(&ins, ":u", pFile->zUuid); | |
| 146 | - db_bind_text(&ins, ":s", pFile->zUuid); | |
| 147 | - /*db_bind_text(&ins, ":u3", pFile->zUuid);*/ | |
| 156 | + db_bind_text( &ins, ":path", &pFile->zName[nD] ); | |
| 157 | + db_bind_text( &ins, ":uuid", pFile->zUuid ); | |
| 148 | 158 | db_step(&ins); |
| 149 | 159 | db_reset(&ins); |
| 150 | 160 | pPrev = pFile; |
| 151 | 161 | for(nPrev=0; (c=pPrev->zName[nD+nPrev]) && c!='/'; nPrev++){} |
| 152 | 162 | if( c=='/' ) nPrev++; |
| @@ -153,56 +163,58 @@ | ||
| 153 | 163 | } |
| 154 | 164 | db_finalize(&ins); |
| 155 | 165 | }else if( zD && *zD ){ |
| 156 | 166 | if( filenames_are_case_sensitive() ){ |
| 157 | 167 | db_multi_exec( |
| 158 | - "INSERT OR IGNORE INTO localfiles" | |
| 168 | + "INSERT OR IGNORE INTO json_dir_files" | |
| 159 | 169 | " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" |
| 160 | 170 | " WHERE name GLOB '%q/*'", |
| 161 | 171 | nD, zD |
| 162 | 172 | ); |
| 163 | 173 | }else{ |
| 164 | 174 | db_multi_exec( |
| 165 | - "INSERT OR IGNORE INTO localfiles" | |
| 175 | + "INSERT OR IGNORE INTO json_dir_files" | |
| 166 | 176 | " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" |
| 167 | 177 | " WHERE name LIKE '%q/%%'", |
| 168 | 178 | nD, zD |
| 169 | 179 | ); |
| 170 | 180 | } |
| 171 | 181 | }else{ |
| 172 | 182 | db_multi_exec( |
| 173 | - "INSERT OR IGNORE INTO localfiles" | |
| 183 | + "INSERT OR IGNORE INTO json_dir_files" | |
| 174 | 184 | " SELECT pathelement(name,0), NULL, NULL, NULL FROM filename" |
| 175 | 185 | ); |
| 176 | 186 | } |
| 177 | 187 | |
| 178 | 188 | if(zCI){ |
| 179 | - db_prepare( &q, "SELECT n as name, u as uuid, sz as size FROM localfiles ORDER BY n"); | |
| 189 | + db_prepare( &q, "SELECT" | |
| 190 | + " n as name," | |
| 191 | + " u as uuid," | |
| 192 | + " sz as size," | |
| 193 | + " mtime as mtime " | |
| 194 | + "FROM json_dir_files ORDER BY n"); | |
| 180 | 195 | }else{/* UUIDs are all NULL. */ |
| 181 | - db_prepare( &q, "SELECT n as name FROM localfiles ORDER BY n"); | |
| 196 | + db_prepare( &q, "SELECT n as name FROM json_dir_files ORDER BY n"); | |
| 182 | 197 | } |
| 183 | 198 | |
| 184 | 199 | zKeyName = cson_new_string("name",4); |
| 185 | - cson_value_add_reference( cson_string_value(zKeyName) ); | |
| 186 | 200 | zKeyUuid = cson_new_string("uuid",4); |
| 187 | - cson_value_add_reference( cson_string_value(zKeyUuid) ); | |
| 188 | 201 | zKeyIsDir = cson_new_string("isDir",5); |
| 189 | - cson_value_add_reference( cson_string_value(zKeyIsDir) ); | |
| 202 | + keyStore = cson_new_array(); | |
| 203 | + cson_array_append( keyStore, cson_string_value(zKeyName) ); | |
| 204 | + cson_array_append( keyStore, cson_string_value(zKeyUuid) ); | |
| 205 | + cson_array_append( keyStore, cson_string_value(zKeyIsDir) ); | |
| 206 | + | |
| 190 | 207 | if( zCI ){ |
| 191 | 208 | zKeySize = cson_new_string("size",4); |
| 192 | - cson_value_add_reference( cson_string_value(zKeySize) ); | |
| 209 | + cson_array_append( keyStore, cson_string_value(zKeySize) ); | |
| 210 | + zKeyTime = cson_new_string("timestamp",9); | |
| 211 | + cson_array_append( keyStore, cson_string_value(zKeyTime) ); | |
| 193 | 212 | } |
| 194 | - | |
| 195 | 213 | zPayload = cson_new_object(); |
| 196 | 214 | cson_object_set_s( zPayload, zKeyName, |
| 197 | 215 | json_new_string((zD&&*zD) ? zD : "/") ); |
| 198 | -#if 0 | |
| 199 | - if(zUuid){ | |
| 200 | - cson_object_set_s( zPayload, zKeyUuid, | |
| 201 | - cson_string_value(cson_new_string(zUuid, strlen(zUuid))) ); | |
| 202 | - } | |
| 203 | -#endif | |
| 204 | 216 | if( zUuid ){ |
| 205 | 217 | cson_object_set( zPayload, "checkin", json_new_string(zUuid) ); |
| 206 | 218 | } |
| 207 | 219 | |
| 208 | 220 | while( (SQLITE_ROW==db_step(&q)) ){ |
| @@ -229,26 +241,23 @@ | ||
| 229 | 241 | associate a single size and uuid with them (and fetching all |
| 230 | 242 | would be overkill for most use cases). |
| 231 | 243 | */ |
| 232 | 244 | char const * u = db_column_text(&q,1); |
| 233 | 245 | sqlite_int64 const sz = db_column_int64(&q,2); |
| 234 | - /*sqlite_int64 const ts = db_column_int64(&q,3);*/ | |
| 246 | + sqlite_int64 const ts = db_column_int64(&q,3); | |
| 235 | 247 | cson_object_set_s(zEntry, zKeyUuid, json_new_string( u ) ); |
| 236 | 248 | cson_object_set_s(zEntry, zKeySize, |
| 237 | 249 | cson_value_new_integer( (cson_int_t)sz )); |
| 238 | - /*cson_object_set(zEntry, "mtime", | |
| 239 | - cson_value_new_integer( (cson_int_t)ts ));*/ | |
| 250 | + cson_object_set_s(zEntry, zKeyTime, | |
| 251 | + cson_value_new_integer( (cson_int_t)ts )); | |
| 240 | 252 | } |
| 241 | 253 | } |
| 242 | 254 | db_finalize(&q); |
| 243 | 255 | if(pM){ |
| 244 | 256 | manifest_destroy(pM); |
| 245 | 257 | } |
| 246 | - cson_value_free( cson_string_value( zKeyName ) ); | |
| 247 | - cson_value_free( cson_string_value( zKeyUuid ) ); | |
| 248 | - cson_value_free( cson_string_value( zKeyIsDir ) ); | |
| 249 | - cson_value_free( cson_string_value( zKeySize ) ); | |
| 258 | + cson_free_array( keyStore ); | |
| 250 | 259 | |
| 251 | 260 | free( zUuid ); |
| 252 | 261 | free( zD ); |
| 253 | 262 | return cson_object_value(zPayload); |
| 254 | 263 | } |
| 255 | 264 |
| --- src/json_dir.c | |
| +++ src/json_dir.c | |
| @@ -51,14 +51,16 @@ | |
| 51 | */ |
| 52 | static cson_value * json_page_dir_list(){ |
| 53 | cson_object * zPayload = NULL; |
| 54 | cson_array * zEntries = NULL; |
| 55 | cson_object * zEntry = NULL; |
| 56 | cson_string * zKeyName = NULL; |
| 57 | cson_string * zKeySize = NULL; |
| 58 | cson_string * zKeyIsDir = NULL; |
| 59 | cson_string * zKeyUuid = NULL; |
| 60 | char * zD = NULL; |
| 61 | char const * zDX = NULL; |
| 62 | int nD; |
| 63 | char * zUuid = NULL; |
| 64 | char const * zCI = NULL; |
| @@ -106,11 +108,11 @@ | |
| 106 | ** Subdirectory names begin with "/". This causes them to sort |
| 107 | ** first and it also gives us an easy way to distinguish files |
| 108 | ** from directories in the loop that follows. |
| 109 | */ |
| 110 | db_multi_exec( |
| 111 | "CREATE TEMP TABLE localfiles(n UNIQUE NOT NULL %s, u, sz, mtime DEFAULT NULL);", |
| 112 | filename_collation() |
| 113 | ); |
| 114 | |
| 115 | if( zCI ){ |
| 116 | Stmt ins; |
| @@ -118,17 +120,27 @@ | |
| 118 | ManifestFile *pPrev = 0; |
| 119 | int nPrev = 0; |
| 120 | int c; |
| 121 | |
| 122 | db_prepare(&ins, |
| 123 | "INSERT OR IGNORE INTO localfiles VALUES(" |
| 124 | /*0*/ "pathelement(:x,0)," |
| 125 | /*1*/ ":u, " |
| 126 | /*2*/ "(SELECT size from blob where uuid=:s), " |
| 127 | /*3: TODO: mtime*/" NULL" |
| 128 | ")" |
| 129 | ); |
| 130 | manifest_file_rewind(pM); |
| 131 | while( (pFile = manifest_file_next(pM,0))!=0 ){ |
| 132 | if( nD>0 |
| 133 | && ((pFile->zName[nD-1]!='/') || (0!=memcmp(pFile->zName, zD, nD-1))) |
| 134 | ){ |
| @@ -139,14 +151,12 @@ | |
| 139 | && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0 |
| 140 | && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/') |
| 141 | ){ |
| 142 | continue; |
| 143 | } |
| 144 | db_bind_text(&ins, ":x", &pFile->zName[nD]); |
| 145 | db_bind_text(&ins, ":u", pFile->zUuid); |
| 146 | db_bind_text(&ins, ":s", pFile->zUuid); |
| 147 | /*db_bind_text(&ins, ":u3", pFile->zUuid);*/ |
| 148 | db_step(&ins); |
| 149 | db_reset(&ins); |
| 150 | pPrev = pFile; |
| 151 | for(nPrev=0; (c=pPrev->zName[nD+nPrev]) && c!='/'; nPrev++){} |
| 152 | if( c=='/' ) nPrev++; |
| @@ -153,56 +163,58 @@ | |
| 153 | } |
| 154 | db_finalize(&ins); |
| 155 | }else if( zD && *zD ){ |
| 156 | if( filenames_are_case_sensitive() ){ |
| 157 | db_multi_exec( |
| 158 | "INSERT OR IGNORE INTO localfiles" |
| 159 | " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" |
| 160 | " WHERE name GLOB '%q/*'", |
| 161 | nD, zD |
| 162 | ); |
| 163 | }else{ |
| 164 | db_multi_exec( |
| 165 | "INSERT OR IGNORE INTO localfiles" |
| 166 | " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" |
| 167 | " WHERE name LIKE '%q/%%'", |
| 168 | nD, zD |
| 169 | ); |
| 170 | } |
| 171 | }else{ |
| 172 | db_multi_exec( |
| 173 | "INSERT OR IGNORE INTO localfiles" |
| 174 | " SELECT pathelement(name,0), NULL, NULL, NULL FROM filename" |
| 175 | ); |
| 176 | } |
| 177 | |
| 178 | if(zCI){ |
| 179 | db_prepare( &q, "SELECT n as name, u as uuid, sz as size FROM localfiles ORDER BY n"); |
| 180 | }else{/* UUIDs are all NULL. */ |
| 181 | db_prepare( &q, "SELECT n as name FROM localfiles ORDER BY n"); |
| 182 | } |
| 183 | |
| 184 | zKeyName = cson_new_string("name",4); |
| 185 | cson_value_add_reference( cson_string_value(zKeyName) ); |
| 186 | zKeyUuid = cson_new_string("uuid",4); |
| 187 | cson_value_add_reference( cson_string_value(zKeyUuid) ); |
| 188 | zKeyIsDir = cson_new_string("isDir",5); |
| 189 | cson_value_add_reference( cson_string_value(zKeyIsDir) ); |
| 190 | if( zCI ){ |
| 191 | zKeySize = cson_new_string("size",4); |
| 192 | cson_value_add_reference( cson_string_value(zKeySize) ); |
| 193 | } |
| 194 | |
| 195 | zPayload = cson_new_object(); |
| 196 | cson_object_set_s( zPayload, zKeyName, |
| 197 | json_new_string((zD&&*zD) ? zD : "/") ); |
| 198 | #if 0 |
| 199 | if(zUuid){ |
| 200 | cson_object_set_s( zPayload, zKeyUuid, |
| 201 | cson_string_value(cson_new_string(zUuid, strlen(zUuid))) ); |
| 202 | } |
| 203 | #endif |
| 204 | if( zUuid ){ |
| 205 | cson_object_set( zPayload, "checkin", json_new_string(zUuid) ); |
| 206 | } |
| 207 | |
| 208 | while( (SQLITE_ROW==db_step(&q)) ){ |
| @@ -229,26 +241,23 @@ | |
| 229 | associate a single size and uuid with them (and fetching all |
| 230 | would be overkill for most use cases). |
| 231 | */ |
| 232 | char const * u = db_column_text(&q,1); |
| 233 | sqlite_int64 const sz = db_column_int64(&q,2); |
| 234 | /*sqlite_int64 const ts = db_column_int64(&q,3);*/ |
| 235 | cson_object_set_s(zEntry, zKeyUuid, json_new_string( u ) ); |
| 236 | cson_object_set_s(zEntry, zKeySize, |
| 237 | cson_value_new_integer( (cson_int_t)sz )); |
| 238 | /*cson_object_set(zEntry, "mtime", |
| 239 | cson_value_new_integer( (cson_int_t)ts ));*/ |
| 240 | } |
| 241 | } |
| 242 | db_finalize(&q); |
| 243 | if(pM){ |
| 244 | manifest_destroy(pM); |
| 245 | } |
| 246 | cson_value_free( cson_string_value( zKeyName ) ); |
| 247 | cson_value_free( cson_string_value( zKeyUuid ) ); |
| 248 | cson_value_free( cson_string_value( zKeyIsDir ) ); |
| 249 | cson_value_free( cson_string_value( zKeySize ) ); |
| 250 | |
| 251 | free( zUuid ); |
| 252 | free( zD ); |
| 253 | return cson_object_value(zPayload); |
| 254 | } |
| 255 |
| --- src/json_dir.c | |
| +++ src/json_dir.c | |
| @@ -51,14 +51,16 @@ | |
| 51 | */ |
| 52 | static cson_value * json_page_dir_list(){ |
| 53 | cson_object * zPayload = NULL; |
| 54 | cson_array * zEntries = NULL; |
| 55 | cson_object * zEntry = NULL; |
| 56 | cson_array * keyStore = NULL; |
| 57 | cson_string * zKeyName = NULL; |
| 58 | cson_string * zKeySize = NULL; |
| 59 | cson_string * zKeyIsDir = NULL; |
| 60 | cson_string * zKeyUuid = NULL; |
| 61 | cson_string * zKeyTime = NULL; |
| 62 | char * zD = NULL; |
| 63 | char const * zDX = NULL; |
| 64 | int nD; |
| 65 | char * zUuid = NULL; |
| 66 | char const * zCI = NULL; |
| @@ -106,11 +108,11 @@ | |
| 108 | ** Subdirectory names begin with "/". This causes them to sort |
| 109 | ** first and it also gives us an easy way to distinguish files |
| 110 | ** from directories in the loop that follows. |
| 111 | */ |
| 112 | db_multi_exec( |
| 113 | "CREATE TEMP TABLE json_dir_files(n UNIQUE NOT NULL %s, u, sz, mtime DEFAULT NULL);", |
| 114 | filename_collation() |
| 115 | ); |
| 116 | |
| 117 | if( zCI ){ |
| 118 | Stmt ins; |
| @@ -118,17 +120,27 @@ | |
| 120 | ManifestFile *pPrev = 0; |
| 121 | int nPrev = 0; |
| 122 | int c; |
| 123 | |
| 124 | db_prepare(&ins, |
| 125 | "INSERT OR IGNORE INTO json_dir_files (n,u,sz,mtime) " |
| 126 | "SELECT" |
| 127 | " pathelement(:path,0)," |
| 128 | " a.uuid," |
| 129 | " a.size," |
| 130 | " CAST(strftime('%%s',e.mtime) AS INTEGER) " |
| 131 | "FROM" |
| 132 | " mlink m, " |
| 133 | " event e," |
| 134 | " blob a," |
| 135 | " blob b " |
| 136 | "WHERE" |
| 137 | " e.objid=m.mid" |
| 138 | " AND a.rid=m.fid"/*FILE artifact*/ |
| 139 | " AND b.rid=m.mid"/*CHECKIN artifact*/ |
| 140 | " AND a.uuid=:uuid" |
| 141 | ); |
| 142 | manifest_file_rewind(pM); |
| 143 | while( (pFile = manifest_file_next(pM,0))!=0 ){ |
| 144 | if( nD>0 |
| 145 | && ((pFile->zName[nD-1]!='/') || (0!=memcmp(pFile->zName, zD, nD-1))) |
| 146 | ){ |
| @@ -139,14 +151,12 @@ | |
| 151 | && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0 |
| 152 | && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/') |
| 153 | ){ |
| 154 | continue; |
| 155 | } |
| 156 | db_bind_text( &ins, ":path", &pFile->zName[nD] ); |
| 157 | db_bind_text( &ins, ":uuid", pFile->zUuid ); |
| 158 | db_step(&ins); |
| 159 | db_reset(&ins); |
| 160 | pPrev = pFile; |
| 161 | for(nPrev=0; (c=pPrev->zName[nD+nPrev]) && c!='/'; nPrev++){} |
| 162 | if( c=='/' ) nPrev++; |
| @@ -153,56 +163,58 @@ | |
| 163 | } |
| 164 | db_finalize(&ins); |
| 165 | }else if( zD && *zD ){ |
| 166 | if( filenames_are_case_sensitive() ){ |
| 167 | db_multi_exec( |
| 168 | "INSERT OR IGNORE INTO json_dir_files" |
| 169 | " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" |
| 170 | " WHERE name GLOB '%q/*'", |
| 171 | nD, zD |
| 172 | ); |
| 173 | }else{ |
| 174 | db_multi_exec( |
| 175 | "INSERT OR IGNORE INTO json_dir_files" |
| 176 | " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" |
| 177 | " WHERE name LIKE '%q/%%'", |
| 178 | nD, zD |
| 179 | ); |
| 180 | } |
| 181 | }else{ |
| 182 | db_multi_exec( |
| 183 | "INSERT OR IGNORE INTO json_dir_files" |
| 184 | " SELECT pathelement(name,0), NULL, NULL, NULL FROM filename" |
| 185 | ); |
| 186 | } |
| 187 | |
| 188 | if(zCI){ |
| 189 | db_prepare( &q, "SELECT" |
| 190 | " n as name," |
| 191 | " u as uuid," |
| 192 | " sz as size," |
| 193 | " mtime as mtime " |
| 194 | "FROM json_dir_files ORDER BY n"); |
| 195 | }else{/* UUIDs are all NULL. */ |
| 196 | db_prepare( &q, "SELECT n as name FROM json_dir_files ORDER BY n"); |
| 197 | } |
| 198 | |
| 199 | zKeyName = cson_new_string("name",4); |
| 200 | zKeyUuid = cson_new_string("uuid",4); |
| 201 | zKeyIsDir = cson_new_string("isDir",5); |
| 202 | keyStore = cson_new_array(); |
| 203 | cson_array_append( keyStore, cson_string_value(zKeyName) ); |
| 204 | cson_array_append( keyStore, cson_string_value(zKeyUuid) ); |
| 205 | cson_array_append( keyStore, cson_string_value(zKeyIsDir) ); |
| 206 | |
| 207 | if( zCI ){ |
| 208 | zKeySize = cson_new_string("size",4); |
| 209 | cson_array_append( keyStore, cson_string_value(zKeySize) ); |
| 210 | zKeyTime = cson_new_string("timestamp",9); |
| 211 | cson_array_append( keyStore, cson_string_value(zKeyTime) ); |
| 212 | } |
| 213 | zPayload = cson_new_object(); |
| 214 | cson_object_set_s( zPayload, zKeyName, |
| 215 | json_new_string((zD&&*zD) ? zD : "/") ); |
| 216 | if( zUuid ){ |
| 217 | cson_object_set( zPayload, "checkin", json_new_string(zUuid) ); |
| 218 | } |
| 219 | |
| 220 | while( (SQLITE_ROW==db_step(&q)) ){ |
| @@ -229,26 +241,23 @@ | |
| 241 | associate a single size and uuid with them (and fetching all |
| 242 | would be overkill for most use cases). |
| 243 | */ |
| 244 | char const * u = db_column_text(&q,1); |
| 245 | sqlite_int64 const sz = db_column_int64(&q,2); |
| 246 | sqlite_int64 const ts = db_column_int64(&q,3); |
| 247 | cson_object_set_s(zEntry, zKeyUuid, json_new_string( u ) ); |
| 248 | cson_object_set_s(zEntry, zKeySize, |
| 249 | cson_value_new_integer( (cson_int_t)sz )); |
| 250 | cson_object_set_s(zEntry, zKeyTime, |
| 251 | cson_value_new_integer( (cson_int_t)ts )); |
| 252 | } |
| 253 | } |
| 254 | db_finalize(&q); |
| 255 | if(pM){ |
| 256 | manifest_destroy(pM); |
| 257 | } |
| 258 | cson_free_array( keyStore ); |
| 259 | |
| 260 | free( zUuid ); |
| 261 | free( zD ); |
| 262 | return cson_object_value(zPayload); |
| 263 | } |
| 264 |