mirror of
				https://github.com/simon987/sist2.git
				synced 2025-10-31 16:06:53 +00:00 
			
		
		
		
	Use 16-bit ints for meta keys (wip)
This commit is contained in:
		
							parent
							
								
									22dd58e140
								
							
						
					
					
						commit
						a01f6dff1f
					
				| @ -40,6 +40,8 @@ typedef struct { | ||||
|     pcre_extra *exclude_extra; | ||||
|     int fast; | ||||
| 
 | ||||
|     GHashTable *dbg_current_files; | ||||
| 
 | ||||
|     scan_arc_ctx_t arc_ctx; | ||||
|     scan_comic_ctx_t comic_ctx; | ||||
|     scan_ebook_ctx_t ebook_ctx; | ||||
|  | ||||
| @ -15,9 +15,13 @@ typedef struct { | ||||
|     char has_parent; | ||||
| } line_t; | ||||
| 
 | ||||
| #define META_NEXT 0xFFFF | ||||
| 
 | ||||
| void skip_meta(FILE *file) { | ||||
|     enum metakey key = getc(file); | ||||
|     while (key != '\n') { | ||||
|     enum metakey key; | ||||
|     fread(&key, sizeof(uint16_t), 1, file); | ||||
| 
 | ||||
|     while (key != META_NEXT) { | ||||
|         if (IS_META_INT(key)) { | ||||
|             fseek(file, sizeof(int), SEEK_CUR); | ||||
|         } else if (IS_META_LONG(key)) { | ||||
| @ -26,7 +30,7 @@ void skip_meta(FILE *file) { | ||||
|             while ((getc(file))) {} | ||||
|         } | ||||
| 
 | ||||
|         key = getc(file); | ||||
|         fread(&key, sizeof(uint16_t), 1, file); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -66,7 +70,7 @@ index_descriptor_t read_index_descriptor(char *path) { | ||||
|     } | ||||
| 
 | ||||
|     char *buf = malloc(info.st_size + 1); | ||||
|     int ret = read(fd, buf, info.st_size); | ||||
|     size_t ret = read(fd, buf, info.st_size); | ||||
|     if (ret == -1) { | ||||
|         LOG_FATALF("serialize.c", "Could not read index descriptor: %s", strerror(errno)); | ||||
|     } | ||||
| @ -152,8 +156,20 @@ char *get_meta_key_text(enum metakey meta_key) { | ||||
|             return "thumbnail"; | ||||
|         case MetaPages: | ||||
|             return "pages"; | ||||
|         case MetaExifGpsLongitudeRef: | ||||
|             return "exif_gps_longitude_ref"; | ||||
|         case MetaExifGpsLongitudeDMS: | ||||
|             return "exif_gps_longitude_dms"; | ||||
|         case MetaExifGpsLongitudeDec: | ||||
|             return "exif_gps_longitude_dec"; | ||||
|         case MetaExifGpsLatitudeRef: | ||||
|             return "exif_gps_latitude_ref"; | ||||
|         case MetaExifGpsLatitudeDMS: | ||||
|             return "exif_gps_latitude_dms"; | ||||
|         case MetaExifGpsLatitudeDec: | ||||
|             return "exif_gps_latitude_dec"; | ||||
|         default: | ||||
|             return NULL; | ||||
|         LOG_FATALF("serialize.c", "FIXME: Unknown meta key: %d", meta_key) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -183,7 +199,7 @@ void write_document(document_t *doc) { | ||||
| 
 | ||||
|     meta_line_t *meta = doc->meta_head; | ||||
|     while (meta != NULL) { | ||||
|         dyn_buffer_write_char(&buf, meta->key); | ||||
|         dyn_buffer_write_short(&buf, (uint16_t) meta->key); | ||||
| 
 | ||||
|         if (IS_META_INT(meta->key)) { | ||||
|             dyn_buffer_write_int(&buf, meta->int_val); | ||||
| @ -197,7 +213,7 @@ void write_document(document_t *doc) { | ||||
|         meta = meta->next; | ||||
|         free(tmp); | ||||
|     } | ||||
|     dyn_buffer_write_char(&buf, '\n'); | ||||
|     dyn_buffer_write_short(&buf, META_NEXT); | ||||
| 
 | ||||
|     int res = write(index_fd, buf.buf, buf.cur); | ||||
|     if (res == -1) { | ||||
| @ -268,9 +284,10 @@ void read_index_bin(const char *path, const char *index_id, index_func func) { | ||||
|             cJSON_AddStringToObject(document, "path", ""); | ||||
|         } | ||||
| 
 | ||||
|         enum metakey key = getc(file); | ||||
|         size_t ret = 0; | ||||
|         while (key != '\n') { | ||||
|         enum metakey key; | ||||
|         fread(&key, sizeof(short), 1, file); | ||||
|         size_t ret; | ||||
|         while (key != META_NEXT) { | ||||
|             switch (key) { | ||||
|                 case MetaPages: | ||||
|                 case MetaWidth: | ||||
| @ -308,6 +325,12 @@ void read_index_bin(const char *path, const char *index_id, index_func func) { | ||||
|                 case MetaAuthor: | ||||
|                 case MetaModifiedBy: | ||||
|                 case MetaThumbnail: | ||||
|                 case MetaExifGpsLongitudeDMS: | ||||
|                 case MetaExifGpsLongitudeDec: | ||||
|                 case MetaExifGpsLongitudeRef: | ||||
|                 case MetaExifGpsLatitudeDMS: | ||||
|                 case MetaExifGpsLatitudeDec: | ||||
|                 case MetaExifGpsLatitudeRef: | ||||
|                 case MetaTitle: { | ||||
|                     buf.cur = 0; | ||||
|                     while ((c = getc(file)) != 0) { | ||||
| @ -323,7 +346,7 @@ void read_index_bin(const char *path, const char *index_id, index_func func) { | ||||
|                 LOG_FATALF("serialize.c", "Invalid meta key (corrupt index): %x", key) | ||||
|             } | ||||
| 
 | ||||
|             key = getc(file); | ||||
|             fread(&key, sizeof(uint16_t), 1, file); | ||||
|         } | ||||
| 
 | ||||
|         cJSON *meta_obj = NULL; | ||||
| @ -510,9 +533,9 @@ void incremental_copy(store_t *store, store_t *dst_store, const char *filepath, | ||||
| 
 | ||||
|             enum metakey key; | ||||
|             while (1) { | ||||
|                 key = getc(file); | ||||
|                 fwrite(&key, sizeof(char), 1, dst_file); | ||||
|                 if (key == '\n') { | ||||
|                 fread(&key, sizeof(uint16_t), 1, file); | ||||
|                 fwrite(&key, sizeof(uint16_t), 1, dst_file); | ||||
|                 if (key == META_NEXT) { | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|  | ||||
| @ -21,7 +21,7 @@ | ||||
| #define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0" | ||||
| 
 | ||||
| 
 | ||||
| static const char *const Version = "2.9.1"; | ||||
| static const char *const Version = "2.10.1"; | ||||
| static const char *const usage[] = { | ||||
|         "sist2 scan [OPTION]... PATH", | ||||
|         "sist2 index [OPTION]... INDEX", | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| 
 | ||||
| <nav class="navbar navbar-expand-lg"> | ||||
|     <a class="navbar-brand" href="/">sist2</a> | ||||
|     <span class="badge badge-pill version">2.9.1</span> | ||||
|     <span class="badge badge-pill version">2.10.1</span> | ||||
|     <span class="tagline">Lightning-fast file system indexer and search tool </span> | ||||
|     <a class="btn ml-auto" href="stats">Stats</a> | ||||
|     <button class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings | ||||
|  | ||||
| @ -10,7 +10,7 @@ | ||||
| 
 | ||||
| <nav class="navbar navbar-expand-lg"> | ||||
|     <a class="navbar-brand" href="/">sist2</a> | ||||
|     <span class="badge badge-pill version">2.9.1</span> | ||||
|     <span class="badge badge-pill version">2.10.1</span> | ||||
|     <span class="tagline">Lightning-fast file system indexer and search tool </span> | ||||
|     <a style="margin-left: auto" class="btn" href="/">Back</a> | ||||
|     <button class="btn" type="button" data-toggle="modal" data-target="#settings" | ||||
|  | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								third-party/argparse
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								third-party/argparse
									
									
									
									
										vendored
									
									
								
							| @ -1 +1 @@ | ||||
| Subproject commit ffd9c23427d0cb105e27f27f0cf97b463b6a8bf8 | ||||
| Subproject commit 5957da0b44d485657edc863b0b924fe837e67b27 | ||||
							
								
								
									
										2
									
								
								third-party/libscan
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								third-party/libscan
									
									
									
									
										vendored
									
									
								
							| @ -1 +1 @@ | ||||
| Subproject commit 8ed4c943141876970e8761993915cfb48df3f189 | ||||
| Subproject commit bcf3e4695b33d65261bac5f75ecf23a0a12fa3a9 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user