Args: file: File returned by file manager Returns: Full path for the file
(file, validate=True)
| 232 | |
| 233 | |
| 234 | def get_complete_file_path(file, validate=True): |
| 235 | """ |
| 236 | Args: |
| 237 | file: File returned by file manager |
| 238 | |
| 239 | Returns: |
| 240 | Full path for the file |
| 241 | """ |
| 242 | if not file: |
| 243 | return None |
| 244 | |
| 245 | # If desktop mode |
| 246 | if current_app.PGADMIN_RUNTIME or not current_app.config['SERVER_MODE']: |
| 247 | return file if os.path.isfile(file) else None |
| 248 | |
| 249 | # get dir name and file name |
| 250 | dir_name, file = get_directory_and_file_name(file) |
| 251 | |
| 252 | storage_dir = get_storage_directory(shared_storage=dir_name) if dir_name \ |
| 253 | else get_storage_directory() |
| 254 | if storage_dir: |
| 255 | file = os.path.join( |
| 256 | storage_dir, |
| 257 | file.lstrip('/').lstrip('\\') |
| 258 | ) |
| 259 | if IS_WIN: |
| 260 | file = file.replace('\\', '/') |
| 261 | file = fs_short_path(file) |
| 262 | |
| 263 | if validate: |
| 264 | return file if os.path.isfile(file) else None |
| 265 | else: |
| 266 | return file |
| 267 | |
| 268 | |
| 269 | def filename_with_file_manager_path(_file, create_file=False, |
no test coverage detected