From c490d2c721f0e21a101f27ed7a671b0b0cc33961 Mon Sep 17 00:00:00 2001 From: Max Lin Date: Fri, 29 Jan 2016 19:42:16 +0800 Subject: [PATCH] Add module name to uploaded files Main goal is avoding the uploaded files be overwritten. Now the uploaded files are named $modulename-$filename --- commands.pm | 13 ++++++++++--- testapi.pm | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/commands.pm b/commands.pm index 1d1ef8d41b7..9cb216e3608 100644 --- a/commands.pm +++ b/commands.pm @@ -170,11 +170,18 @@ sub upload_file { mkdir($target) or die "$!"; } - my $upname = basename($self->param('filename')); + my $upname = $self->param('upname'); + my $filename = basename($self->param('filename')); + # Only renaming the file if upname parameter has posted ie. from upload_logs() + # With this it won't renamed the file in case upload_assert and autoyast profile + # as those are not called from upload_logs. + if ($upname) { + $filename = basename($upname); + } - $upload->move_to("$target/$upname"); + $upload->move_to("$target/$filename"); - return $self->render(text => "OK: $upname\n"); + return $self->render(text => "OK: $filename\n"); } diff --git a/testapi.pm b/testapi.pm index ecf8980bf06..8be3c53026c 100755 --- a/testapi.pm +++ b/testapi.pm @@ -390,8 +390,9 @@ sub upload_logs { my ($file) = @_; bmwqemu::log_call('upload_logs', file => $file); - my $cmd = "curl --form upload=\@$file "; my $basename = basename($file); + my $upname = ref($autotest::current_test) . '-' . $basename; + my $cmd = "curl --form upload=\@$file --form upname=$upname "; $cmd .= autoinst_url("/uploadlog/$basename"); return assert_script_run($cmd); }