Index: src/json_dir.c ================================================================== --- src/json_dir.c +++ src/json_dir.c @@ -106,11 +106,11 @@ ** Subdirectory names begin with "/". This causes them to sort ** first and it also gives us an easy way to distinguish files ** from directories in the loop that follows. */ db_multi_exec( - "CREATE TEMP TABLE localfiles(x UNIQUE NOT NULL %s, u, sz);", + "CREATE TEMP TABLE localfiles(n UNIQUE NOT NULL %s, u, sz, mtime DEFAULT NULL);", filename_collation() ); if( zCI ){ Stmt ins; @@ -118,12 +118,15 @@ ManifestFile *pPrev = 0; int nPrev = 0; int c; db_prepare(&ins, - "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u, " - "(SELECT size from blob where uuid=:s)" + "INSERT OR IGNORE INTO localfiles VALUES(" + /*0*/ "pathelement(:x,0)," + /*1*/ ":u, " + /*2*/ "(SELECT size from blob where uuid=:s), " + /*3: TODO: mtime*/" NULL" ")" ); manifest_file_rewind(pM); while( (pFile = manifest_file_next(pM,0))!=0 ){ if( nD>0 @@ -139,10 +142,11 @@ continue; } db_bind_text(&ins, ":x", &pFile->zName[nD]); db_bind_text(&ins, ":u", pFile->zUuid); db_bind_text(&ins, ":s", pFile->zUuid); + /*db_bind_text(&ins, ":u3", pFile->zUuid);*/ db_step(&ins); db_reset(&ins); pPrev = pFile; for(nPrev=0; (c=pPrev->zName[nD+nPrev]) && c!='/'; nPrev++){} if( c=='/' ) nPrev++; @@ -150,33 +154,33 @@ db_finalize(&ins); }else if( zD && *zD ){ if( filenames_are_case_sensitive() ){ db_multi_exec( "INSERT OR IGNORE INTO localfiles" - " SELECT pathelement(name,%d), NULL, NULL FROM filename" + " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" " WHERE name GLOB '%q/*'", nD, zD ); }else{ db_multi_exec( "INSERT OR IGNORE INTO localfiles" - " SELECT pathelement(name,%d), NULL FROM filename" + " SELECT pathelement(name,%d), NULL, NULL, NULL FROM filename" " WHERE name LIKE '%q/%%'", nD, zD ); } }else{ db_multi_exec( "INSERT OR IGNORE INTO localfiles" - " SELECT pathelement(name,0), NULL FROM filename" + " SELECT pathelement(name,0), NULL, NULL, NULL FROM filename" ); } if(zCI){ - db_prepare( &q, "SELECT x as name, u as uuid, sz as size FROM localfiles ORDER BY x"); + db_prepare( &q, "SELECT n as name, u as uuid, sz as size FROM localfiles ORDER BY n"); }else{/* UUIDs are all NULL. */ - db_prepare( &q, "SELECT x as name FROM localfiles ORDER BY x"); + db_prepare( &q, "SELECT n as name FROM localfiles ORDER BY n"); } zKeyName = cson_new_string("name",4); cson_value_add_reference( cson_string_value(zKeyName) ); zKeyUuid = cson_new_string("uuid",4); @@ -189,16 +193,18 @@ } zPayload = cson_new_object(); cson_object_set_s( zPayload, zKeyName, json_new_string((zD&&*zD) ? zD : "/") ); +#if 0 if(zUuid){ cson_object_set_s( zPayload, zKeyUuid, cson_string_value(cson_new_string(zUuid, strlen(zUuid))) ); } - if( zCI ){ - cson_object_set( zPayload, "checkin", json_new_string(zCI) ); +#endif + if( zUuid ){ + cson_object_set( zPayload, "checkin", json_new_string(zUuid) ); } while( (SQLITE_ROW==db_step(&q)) ){ cson_value * name = NULL; char const * n = db_column_text(&q,0); @@ -214,22 +220,23 @@ cson_object_set_s(zEntry, zKeyIsDir, cson_value_true() ); } else{ name = json_new_string( n ); } cson_object_set_s(zEntry, zKeyName, name ); - if( zCI ){ + if( zCI && !isDir){ + /* don't add the uuid/size for dir entries - that data refers + to one of the files in that directory :/. */ char const * u = db_column_text(&q,1); sqlite_int64 const sz = db_column_int64(&q,2); - if(!isDir){ - /* don't add the uuid/size for dir entries - that data refers - to one of the files in that directory :/. */ - if(u && *u){ - cson_object_set_s(zEntry, zKeyUuid, json_new_string( u ) ); - } - cson_object_set_s(zEntry, zKeySize, - cson_value_new_integer( (cson_int_t)sz )); + /*sqlite_int64 const ts = db_column_int64(&q,3);*/ + if(u && *u){ + cson_object_set_s(zEntry, zKeyUuid, json_new_string( u ) ); } + cson_object_set_s(zEntry, zKeySize, + cson_value_new_integer( (cson_int_t)sz )); + /*cson_object_set(zEntry, "mtime", + cson_value_new_integer( (cson_int_t)ts ));*/ } } db_finalize(&q); if(pM){ manifest_destroy(pM);