@@ -417,18 +417,6 @@ Status CloudFileSystemOptions::Serialize(const ConfigOptions& config_options,
417417 reinterpret_cast <const char *>(this ), value);
418418}
419419
420- CloudFileSystemEnv::CloudFileSystemEnv (const CloudFileSystemOptions& options,
421- const std::shared_ptr<FileSystem>& base,
422- const std::shared_ptr<Logger>& logger)
423- : cloud_fs_options(options), base_fs_(base), info_log_(logger) {
424- RegisterOptions (&cloud_fs_options, &cloud_fs_option_type_info);
425- }
426-
427- CloudFileSystemEnv::~CloudFileSystemEnv () {
428- cloud_fs_options.cloud_log_controller .reset ();
429- cloud_fs_options.storage_provider .reset ();
430- }
431-
432420Status CloudFileSystemEnv::NewAwsFileSystem (
433421 const std::shared_ptr<FileSystem>& base_fs,
434422 const std::string& src_cloud_bucket, const std::string& src_cloud_object,
@@ -492,12 +480,13 @@ void CloudFileSystemEnv::RegisterCloudObjects(const std::string& arg) {
492480 });
493481}
494482
495- std::unique_ptr<Env> CloudFileSystemEnv::NewCompositeEnvFromThis (Env* env) {
483+ std::unique_ptr<Env> CloudFileSystemEnv::NewCompositeEnvFromFs (FileSystem* fs,
484+ Env* env) {
496485 // We need a shared_ptr<FileSystem> pointing to "this", to initialize the
497486 // env wrapper, but we don't want that shared_ptr to own the lifecycle for
498487 // "this". Creating a shared_ptr with a custom no-op deleter instead.
499- std::shared_ptr<FileSystem> fs ( this , [](auto * /* p*/ ) { /* noop*/ });
500- return std::make_unique<CompositeEnvWrapper>(env, fs );
488+ std::shared_ptr<FileSystem> fsPtr (fs , [](auto * /* p*/ ) { /* noop*/ });
489+ return std::make_unique<CompositeEnvWrapper>(env, fsPtr );
501490}
502491
503492Status CloudFileSystemEnv::CreateFromString (
@@ -529,13 +518,13 @@ Status CloudFileSystemEnv::CreateFromString(
529518 copy.invoke_prepare_options = false ; // Prepare here, not there
530519 s = ObjectRegistry::NewInstance ()->NewUniqueObject <FileSystem>(id, &fs);
531520 if (s.ok ()) {
532- auto * cfs = dynamic_cast <CloudFileSystemEnv *>(fs.get ());
521+ auto * cfs = dynamic_cast <CloudFileSystemImpl *>(fs.get ());
533522 assert (cfs);
534523 if (!options.empty ()) {
535524 s = cfs->ConfigureFromMap (copy, options);
536525 }
537526 if (s.ok () && config_options.invoke_prepare_options ) {
538- auto env = cfs-> NewCompositeEnvFromThis ( copy.env );
527+ auto env = NewCompositeEnvFromFs (cfs, copy.env );
539528 copy.invoke_prepare_options = config_options.invoke_prepare_options ;
540529 copy.env = env.get ();
541530 s = cfs->PrepareOptions (copy);
@@ -583,15 +572,15 @@ Status CloudFileSystemEnv::CreateFromString(
583572 copy.invoke_prepare_options = false ; // Prepare here, not there
584573 s = ObjectRegistry::NewInstance ()->NewUniqueObject <FileSystem>(id, &fs);
585574 if (s.ok ()) {
586- auto * cfs = dynamic_cast <CloudFileSystemEnv *>(fs.get ());
575+ auto * cfs = dynamic_cast <CloudFileSystemImpl *>(fs.get ());
587576 assert (cfs);
588577 auto copts = cfs->GetOptions <CloudFileSystemOptions>();
589578 *copts = cloud_options;
590579 if (!options.empty ()) {
591580 s = cfs->ConfigureFromMap (copy, options);
592581 }
593582 if (s.ok () && config_options.invoke_prepare_options ) {
594- auto env = cfs-> NewCompositeEnvFromThis ( copy.env );
583+ auto env = NewCompositeEnvFromFs (cfs, copy.env );
595584 copy.invoke_prepare_options = config_options.invoke_prepare_options ;
596585 copy.env = env.get ();
597586 s = cfs->PrepareOptions (copy);
0 commit comments