Skip to content

Commit 2850be3

Browse files
committed
Optimize update_docker_compose fn
Signed-off-by: Riddhesh Sanghvi <[email protected]>
1 parent 74a4d78 commit 2850be3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

php/EE/Migration/Containers.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ public static function update_docker_compose() {
132132
$docker_compose_path = EE::launch( 'command -v docker-compose' )->stdout;
133133
$docker_compose_path = trim( $docker_compose_path );
134134
$docker_compose_backup_path = EE_BACKUP_DIR . '/docker-compose.backup';
135-
$fs = new Filesystem();
136-
if ( ! $fs->exists( EE_BACKUP_DIR ) ) {
137-
$fs->mkdir( EE_BACKUP_DIR );
138-
}
139-
$fs->copy( $docker_compose_path, $docker_compose_backup_path );
140135

141136
if ( version_compare( '2.27.0', $docker_compose_version, '>' ) ) {
137+
138+
$fs = new Filesystem();
139+
if ( ! $fs->exists( EE_BACKUP_DIR ) ) {
140+
$fs->mkdir( EE_BACKUP_DIR );
141+
}
142+
$fs->copy( $docker_compose_path, $docker_compose_backup_path );
143+
142144
EE::exec( "curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m) -o $docker_compose_path && chmod +x $docker_compose_path" );
143145
}
144146
}

0 commit comments

Comments
 (0)