diff options
author | Reinier van der Leer <pwuts@agpt.co> | 2024-03-20 17:13:47 +0100 |
---|---|---|
committer | Reinier van der Leer <pwuts@agpt.co> | 2024-03-20 17:13:47 +0100 |
commit | 596487b9ad70c34fcb0075f24e6031a896841c0f (patch) | |
tree | 327a5928f0eebc03921f8b008bbdd49a0a5d0b5d | |
parent | fix(agent): Fix and windows-proof `scan_plugins` (diff) | |
download | Auto-GPT-596487b9ad70c34fcb0075f24e6031a896841c0f.tar.gz Auto-GPT-596487b9ad70c34fcb0075f24e6031a896841c0f.tar.bz2 Auto-GPT-596487b9ad70c34fcb0075f24e6031a896841c0f.zip |
fix(agent): Windows-proof file_operations
Make file_operations and test_file_operations behave more consistently between Unix and Windows
-rw-r--r-- | autogpts/autogpt/autogpt/commands/file_operations.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/autogpts/autogpt/autogpt/commands/file_operations.py b/autogpts/autogpt/autogpt/commands/file_operations.py index 57cfc5986..55149216f 100644 --- a/autogpts/autogpt/autogpt/commands/file_operations.py +++ b/autogpts/autogpt/autogpt/commands/file_operations.py @@ -92,9 +92,9 @@ def is_duplicate_operation( True if the operation has already been performed on the file """ state = file_operations_state(agent.get_file_operation_lines()) - if operation == "delete" and str(file_path) not in state: + if operation == "delete" and file_path.as_posix() not in state: return True - if operation == "write" and state.get(str(file_path)) == checksum: + if operation == "write" and state.get(file_path.as_posix()) == checksum: return True return False @@ -113,11 +113,14 @@ async def log_operation( file_path: The name of the file the operation was performed on checksum: The checksum of the contents to be written """ - log_entry = f"{operation}: {file_path}" + log_entry = ( + f"{operation}: " + f"{file_path.as_posix() if isinstance(file_path, Path) else file_path}" + ) if checksum is not None: log_entry += f" #{checksum}" logger.debug(f"Logging file operation: {log_entry}") - await agent.log_file_operation(f"{log_entry}") + await agent.log_file_operation(log_entry) @command( |