[phodav,10/13] spice-win: don't assign drive_letter on error

Submitted by Jakub Janku on May 23, 2019, 8:37 a.m.

Details

Message ID 20190523083725.1554-11-jjanku@redhat.com
State New
Headers show
Series "Miscellaneous series" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Jakub Janku May 23, 2019, 8:37 a.m.
drive_letter should be assigned only when the mapping was successful.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
---
 spice/spice-webdavd.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
index 29058e7..f2c7f07 100644
--- a/spice/spice-webdavd.c
+++ b/spice/spice-webdavd.c
@@ -910,14 +910,20 @@  map_drive_cb(GTask *task,
           break;
         }
 
-      if (map_drive (drive_letter) != ERROR_ALREADY_ASSIGNED)
+      ret = map_drive (drive_letter);
+      if (ret == ERROR_ALREADY_ASSIGNED)
         {
-          break;
+          /* try again with another letter */
+          continue;
+        }
+      if (ret != NO_ERROR)
+        {
+          drive_letter = 0;
         }
+      break;
       //TODO: After mapping, rename network drive from \\localhost@PORT\DavWWWRoot
       //      to something like SPICE Shared Folder
     }
-
   g_mutex_lock(&map_drive_data->service_data->mutex);
   map_drive_data->service_data->drive_letter = drive_letter;
   g_mutex_unlock(&map_drive_data->service_data->mutex);

Comments

On Thu, May 23, 2019 at 10:37 AM Jakub Janků <jjanku@redhat.com> wrote:
>
> drive_letter should be assigned only when the mapping was successful.
>
> Signed-off-by: Jakub Janků <jjanku@redhat.com>

ack

>  spice/spice-webdavd.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
> index 29058e7..f2c7f07 100644
> --- a/spice/spice-webdavd.c
> +++ b/spice/spice-webdavd.c
> @@ -910,14 +910,20 @@ map_drive_cb(GTask *task,
>            break;
>          }
>
> -      if (map_drive (drive_letter) != ERROR_ALREADY_ASSIGNED)
> +      ret = map_drive (drive_letter);
> +      if (ret == ERROR_ALREADY_ASSIGNED)
>          {
> -          break;
> +          /* try again with another letter */
> +          continue;
> +        }
> +      if (ret != NO_ERROR)
> +        {
> +          drive_letter = 0;
>          }
> +      break;
>        //TODO: After mapping, rename network drive from \\localhost@PORT\DavWWWRoot
>        //      to something like SPICE Shared Folder
>      }
> -
>    g_mutex_lock(&map_drive_data->service_data->mutex);
>    map_drive_data->service_data->drive_letter = drive_letter;
>    g_mutex_unlock(&map_drive_data->service_data->mutex);
> --
> 2.21.0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel