@@ -290,26 +290,31 @@ EXPORT bool create_directory_or_throw(const std::string& path) {
290
290
// this function throws if the directory still doesn't exist
291
291
// at that location
292
292
if (get_protocol (path) == " s3" ) {
293
- auto status = get_file_status (path);
293
+ // only check on parent direcotory or prefix
294
+ auto ppath = get_dirname (path);
295
+ auto status = get_file_status (ppath);
296
+ // no need to create subdirectory in s3 because there's none
294
297
switch (status.first ) {
295
298
case file_status::MISSING:
296
299
log_and_throw_io_failure (
297
- " Unable to create directory structure at " + sanitize_url (path) +
298
- " . Ensure that you have write permission to this location, or try "
299
- " again with a different path. " +
300
- " error message: " + status.second );
301
- break ;
300
+ " Unable to find parent directory structure: " +
301
+ sanitize_url (ppath) +
302
+ " . Ensure that you have created this s3 prefix. This behavior "
303
+ " intends to avoid accidental creation S3 keys. or try "
304
+ " again with a different path. Error message: " +
305
+ status.second );
302
306
case file_status::REGULAR_FILE:
303
307
log_and_throw_io_failure (
304
- " Unable to create directory at " + sanitize_url (path) +
305
- " . A non-directory file already exists there. Delete that file, or "
306
- " try again with a different path." );
308
+ " Parent directory (prefix) " + sanitize_url (path) +
309
+ " is a regular file. Use prefix as both file and directory is "
310
+ " discouraged in order to prevent further ambiguity. Delete that "
311
+ " file, or try again with a different path." );
307
312
case file_status::DIRECTORY:
308
313
// happy path, return below
309
314
break ;
310
315
default :
311
316
// not sure what error message to give; fall back to current I/O error
312
- log_and_throw_current_io_failure ( );
317
+ log_and_throw_io_failure ( " Unknown error " );
313
318
}
314
319
}
315
320
0 commit comments