A photo manager for VRChat.

hotfix 1

Changed files
+55 -12
src
Components
src-tauri
+4 -1
changelog
··· 37 37 38 38 Dev Stuff: 39 39 - Fixed indentation to be more constistant 40 - - main.rs is no longer like 400 quintillion lines long 40 + - main.rs is no longer like 400 quintillion lines long 41 + 42 + Hotfix 1: 43 + - Fixed photos with legacy naming scheme not loading
+1 -1
src-tauri/Cargo.lock
··· 5036 5036 5037 5037 [[package]] 5038 5038 name = "vrcpm-rs" 5039 - version = "0.2.0" 5039 + version = "0.2.0-hot1" 5040 5040 dependencies = [ 5041 5041 "dirs", 5042 5042 "fast_image_resize",
+1 -1
src-tauri/Cargo.toml
··· 1 1 [package] 2 2 name = "vrcpm-rs" 3 - version = "0.2.0" 3 + version = "0.2.0-hot1" 4 4 description = "VRChat Photo Manager" 5 5 authors = ["_phaz"] 6 6 edition = "2021"
+1 -1
src-tauri/src/frontend_calls/load_photo_meta.rs
··· 24 24 .unwrap(); 25 25 } 26 26 Err(_) => { 27 - println!("Cannot read image file"); 27 + println!("Cannot read image file: {:?}", base_dir); 28 28 } 29 29 } 30 30 });
+16 -4
src-tauri/src/frontend_calls/load_photos.rs
··· 32 32 let re1 = Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}.png").unwrap(); 33 33 let re2 = Regex::new( 34 34 r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap(); 35 + let re3 = Regex::new("VRChat_[0-9]{4}x[0-9]{4}_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}.png").unwrap(); 35 36 36 - if re1.is_match(p.file_name().to_str().unwrap()) 37 - || re2.is_match(p.file_name().to_str().unwrap()) 37 + let name = p.file_name(); 38 + let name = name.to_str().unwrap(); 39 + 40 + let re3_match = re3.is_match(name); 41 + 42 + if re1.is_match(name) 43 + || re2.is_match(name) 44 + || re3_match 38 45 { 39 46 let path = fname.to_path_buf().clone(); 40 47 let metadata = fs::metadata(&path).unwrap(); ··· 42 49 if metadata.is_file() { 43 50 size += metadata.len() as usize; 44 51 45 - let path = path.strip_prefix(&base_dir).unwrap().to_path_buf(); 46 - photos.push(path); 52 + let pth = path.strip_prefix(&base_dir).unwrap().to_path_buf(); 53 + 54 + if re3_match{ 55 + photos.push(path::PathBuf::from("legacy://").join(pth)); 56 + } else{ 57 + photos.push(pth); 58 + } 47 59 } 48 60 } else { 49 61 println!("Ignoring {:#?} as it doesn't match regex", p.file_name());
+32 -4
src/Components/PhotoList.tsx
··· 125 125 scaledHeight?: number; 126 126 127 127 dateString: string; 128 + date: Date; 129 + 130 + legacy: boolean = false; 128 131 129 132 public onMetaLoaded: () => void = () => {}; 130 133 131 - constructor( path: string ){ 134 + constructor( path: string, isLegacy: boolean = false ){ 132 135 this.path = path; 133 - this.dateString = this.path.split('_')[1]; 136 + this.legacy = isLegacy; 137 + 138 + if(this.legacy) 139 + this.dateString = this.path.split('_')[2]; 140 + else 141 + this.dateString = this.path.split('_')[1]; 142 + 143 + let splitDateString = this.dateString.split('-'); 144 + 145 + this.date = new Date(); 146 + 147 + this.date.setFullYear(parseInt(splitDateString[0])); 148 + this.date.setMonth(parseInt(splitDateString[1])); 149 + this.date.setDate(parseInt(splitDateString[2])); 134 150 } 135 151 136 152 loadMeta(){ ··· 453 469 props.setPhotoCount(photoPaths.length); 454 470 props.setPhotoSize(event.payload.size); 455 471 472 + let doesHaveLegacy = false; 473 + 456 474 photoPaths.forEach(( path: string ) => { 457 - let photo = new Photo(path); 458 - photos.push(photo); 475 + let photo 459 476 477 + if(path.slice(0, 9) === "legacy://"){ 478 + photo = new Photo(path.slice(9), true); 479 + doesHaveLegacy = true; 480 + } else 481 + photo = new Photo(path, false); 482 + 483 + photos.push(photo); 460 484 photo.loadMeta(); 461 485 }) 486 + 487 + if(doesHaveLegacy){ 488 + photos = photos.sort(( a, b ) => b.date.valueOf() - a.date.valueOf()); 489 + } 462 490 }) 463 491 } 464 492