Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-4850

Write the device UUID only when it does not exist

    XMLWordPrintableJSON

    Details

      Description

      Currently, the device UUID is writen back to the IsolatedStorageFile in every run even when it is not necessary.

      On CordovaView.xaml.cs:

      string deviceUUID = "";
      
      using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
      {
          try
          {
              IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage);
      
              using (StreamReader reader = new StreamReader(fileStream))
              {
                  deviceUUID = reader.ReadLine();
              }
          }
          catch (Exception /*ex*/)
          {
              deviceUUID = Guid.NewGuid().ToString();
          }
      
          Debug.WriteLine("Updating IsolatedStorage for APP:DeviceID :: " + deviceUUID);
          IsolatedStorageFileStream file = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Create, FileAccess.Write, appStorage);
          using (StreamWriter writeFile = new StreamWriter(file))
          {
              writeFile.WriteLine(deviceUUID);
              writeFile.Close();
          }
      
      }
      

      The writing code should be moved into the catch after creating a new one as:

      catch (Exception /*ex*/)
          {
              deviceUUID = Guid.NewGuid().ToString();
      
              IsolatedStorageFileStream file = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Create, FileAccess.Write, appStorage);
              using (StreamWriter writeFile = new StreamWriter(file))
              {
                  writeFile.WriteLine(deviceUUID);
                  writeFile.Close();
              }
          }
      

        Attachments

          Activity

            People

            • Assignee:
              purplecabbage Jesse MacFadyen
              Reporter:
              jonathannaguin Jonathan Naguin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: