Remove unnecessary .absolute_path thanks to fspath.
This commit is contained in:
		
							parent
							
								
									71de72c776
								
							
						
					
					
						commit
						d8cc841f5c
					
				
					 3 changed files with 12 additions and 13 deletions
				
			
		|  | @ -971,22 +971,21 @@ class Photo(ObjectBase): | ||||||
|         self.photodb.delete(table=Photo, pairs={'id': self.id}) |         self.photodb.delete(table=Photo, pairs={'id': self.id}) | ||||||
| 
 | 
 | ||||||
|         if delete_file and self.real_path.exists: |         if delete_file and self.real_path.exists: | ||||||
|             path = self.real_path.absolute_path |  | ||||||
|             if self.photodb.config['recycle_instead_of_delete']: |             if self.photodb.config['recycle_instead_of_delete']: | ||||||
|                 log.debug('Recycling %s.', path) |                 log.debug('Recycling %s.', self.real_path.absolute_path) | ||||||
|                 action = send2trash.send2trash |                 action = send2trash.send2trash | ||||||
|             else: |             else: | ||||||
|                 log.debug('Deleting %s.', path) |                 log.debug('Deleting %s.', self.real_path.absolute_path) | ||||||
|                 action = os.remove |                 action = os.remove | ||||||
| 
 | 
 | ||||||
|             self.photodb.on_commit_queue.append({ |             self.photodb.on_commit_queue.append({ | ||||||
|                 'action': action, |                 'action': action, | ||||||
|                 'args': [path], |                 'args': [self.real_path], | ||||||
|             }) |             }) | ||||||
|             if self.thumbnail and self.thumbnail.is_file: |             if self.thumbnail and self.thumbnail.is_file: | ||||||
|                 self.photodb.on_commit_queue.append({ |                 self.photodb.on_commit_queue.append({ | ||||||
|                     'action': action, |                     'action': action, | ||||||
|                     'args': [self.thumbnail.absolute_path], |                     'args': [self.thumbnail], | ||||||
|                 }) |                 }) | ||||||
| 
 | 
 | ||||||
|         self._uncache() |         self._uncache() | ||||||
|  | @ -1379,7 +1378,7 @@ class Photo(ObjectBase): | ||||||
|             # If we're on the same partition, make a hardlink. |             # If we're on the same partition, make a hardlink. | ||||||
|             # Otherwise make a copy. |             # Otherwise make a copy. | ||||||
|             try: |             try: | ||||||
|                 os.link(old_path.absolute_path, new_path.absolute_path) |                 os.link(old_path, new_path) | ||||||
|             except OSError: |             except OSError: | ||||||
|                 spinal.copy_file(old_path, new_path) |                 spinal.copy_file(old_path, new_path) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ def export_symlinks_albums(albums, destination, dry_run): | ||||||
|                 yield symlink_dir |                 yield symlink_dir | ||||||
|                 continue |                 continue | ||||||
|             print(album, symlink_dir) |             print(album, symlink_dir) | ||||||
|             os.symlink(src=album_dir.absolute_path, dst=symlink_dir.absolute_path) |             os.symlink(src=album_dir, dst=symlink_dir) | ||||||
|             yield symlink_dir |             yield symlink_dir | ||||||
| 
 | 
 | ||||||
| def export_symlinks_photos(photos, destination, dry_run): | def export_symlinks_photos(photos, destination, dry_run): | ||||||
|  | @ -48,7 +48,7 @@ def export_symlinks_photos(photos, destination, dry_run): | ||||||
|             yield symlink_path |             yield symlink_path | ||||||
|             continue |             continue | ||||||
|         print(symlink_path.absolute_path) |         print(symlink_path.absolute_path) | ||||||
|         os.symlink(src=photo.real_path.absolute_path, dst=symlink_path.absolute_path) |         os.symlink(src=photo.real_path, dst=symlink_path) | ||||||
|         yield symlink_path |         yield symlink_path | ||||||
| 
 | 
 | ||||||
| def get_photos_by_glob(pattern): | def get_photos_by_glob(pattern): | ||||||
|  | @ -266,9 +266,9 @@ def export_symlinks_argparse(args): | ||||||
|     symlinks = symlinks.difference(total_paths) |     symlinks = symlinks.difference(total_paths) | ||||||
|     for old_symlink in symlinks: |     for old_symlink in symlinks: | ||||||
|         print(f'Pruning {old_symlink}.') |         print(f'Pruning {old_symlink}.') | ||||||
|         os.remove(old_symlink.absolute_path) |         os.remove(old_symlink) | ||||||
|         if not old_symlink.parent.listdir(): |         if not old_symlink.parent.listdir(): | ||||||
|             os.rmdir(old_symlink.parent.absolute_path) |             os.rmdir(old_symlink.parent) | ||||||
| 
 | 
 | ||||||
|     checkdirs = set(spinal.walk(destination, yield_directories=True, yield_files=False)) |     checkdirs = set(spinal.walk(destination, yield_directories=True, yield_files=False)) | ||||||
|     while checkdirs: |     while checkdirs: | ||||||
|  | @ -276,7 +276,7 @@ def export_symlinks_argparse(args): | ||||||
|         if check not in destination: |         if check not in destination: | ||||||
|             continue |             continue | ||||||
|         if len(check.listdir()) == 0: |         if len(check.listdir()) == 0: | ||||||
|             os.rmdir(check.absolute_path) |             os.rmdir(check) | ||||||
|             checkdirs.add(check.parent) |             checkdirs.add(check.parent) | ||||||
| 
 | 
 | ||||||
|     return 0 |     return 0 | ||||||
|  |  | ||||||
|  | @ -666,11 +666,11 @@ def upgrade_19_to_20(photodb): | ||||||
|         if len(new.listdir()) > 0: |         if len(new.listdir()) > 0: | ||||||
|             raise Exception(f'{new.absolute_path} already has items in it.') |             raise Exception(f'{new.absolute_path} already has items in it.') | ||||||
|         else: |         else: | ||||||
|             os.rmdir(new.absolute_path) |             os.rmdir(new) | ||||||
| 
 | 
 | ||||||
|     photodb.execute('UPDATE photos SET thumbnail = REPLACE(thumbnail, "/site_thumbnails/", "/thumbnails/")') |     photodb.execute('UPDATE photos SET thumbnail = REPLACE(thumbnail, "/site_thumbnails/", "/thumbnails/")') | ||||||
|     photodb.execute('UPDATE photos SET thumbnail = REPLACE(thumbnail, "\\site_thumbnails\\", "\\thumbnails\\")') |     photodb.execute('UPDATE photos SET thumbnail = REPLACE(thumbnail, "\\site_thumbnails\\", "\\thumbnails\\")') | ||||||
|     photodb.on_commit_queue.append({'action': os.rename, 'args': (old.absolute_path, new.absolute_path)}) |     photodb.on_commit_queue.append({'action': os.rename, 'args': (old, new)}) | ||||||
| 
 | 
 | ||||||
| def upgrade_all(data_directory): | def upgrade_all(data_directory): | ||||||
|     ''' |     ''' | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue