Просмотр исходного кода

chore: fix open application error when upgrade to 0.0.5.1

appflowy 2 лет назад
Родитель
Сommit
f792283e70

+ 3 - 4
frontend/rust-lib/flowy-folder/src/services/persistence/migration.rs

@@ -78,7 +78,7 @@ impl FolderMigration {
 
         let folder = FolderPad::new(workspaces, trash)?;
         KV::set_bool(&key, true);
-        tracing::trace!("Run folder v1 migration");
+        tracing::info!("Run folder v1 migration");
         Ok(Some(folder))
     }
 
@@ -89,11 +89,10 @@ impl FolderMigration {
         }
         let _ = self.migration_folder_rev_struct(folder_id).await?;
         KV::set_bool(&key, true);
-        tracing::trace!("Run folder v2 migration");
+        // tracing::info!("Run folder v2 migration");
         Ok(())
     }
 
-    #[allow(dead_code)]
     pub async fn run_v3_migration(&self, folder_id: &FolderId) -> FlowyResult<()> {
         let key = migration_flag_key(&self.user_id, V3_MIGRATION);
         if KV::get_bool(&key) {
@@ -101,7 +100,7 @@ impl FolderMigration {
         }
         let _ = self.migration_folder_rev_struct(folder_id).await?;
         KV::set_bool(&key, true);
-        tracing::trace!("Run folder v3 migration");
+        tracing::info!("Run folder v3 migration");
         Ok(())
     }
 

+ 1 - 2
frontend/rust-lib/flowy-folder/src/services/persistence/mod.rs

@@ -101,8 +101,7 @@ impl FolderPersistence {
         }
 
         let _ = migrations.run_v2_migration(folder_id).await?;
-
-        // let _ = migrations.run_v3_migration(folder_id).await?;
+        let _ = migrations.run_v3_migration(folder_id).await?;
         Ok(())
     }
 

+ 1 - 0
frontend/rust-lib/flowy-grid/src/services/field/type_options/text_type_option/text_type_option.rs

@@ -29,6 +29,7 @@ impl TypeOptionBuilder for RichTextTypeOptionBuilder {
 #[derive(Debug, Clone, Default, Serialize, Deserialize, ProtoBuf)]
 pub struct RichTextTypeOptionPB {
     #[pb(index = 1)]
+    #[serde(default)]
     data: String, //It's not used yet
 }
 impl_type_option!(RichTextTypeOptionPB, FieldType::RichText);

+ 14 - 2
shared-lib/flowy-sync/src/client_grid/view_revision_pad.rs

@@ -23,6 +23,8 @@ impl std::ops::Deref for GridViewRevisionPad {
 }
 
 impl GridViewRevisionPad {
+    // For the moment, the view_id is equal to grid_id. The grid_id represents the database id.
+    // A database can be referenced by multiple views.
     pub fn new(grid_id: String, view_id: String) -> Self {
         let view = Arc::new(GridViewRevision::new(grid_id, view_id));
         let json = serde_json::to_string(&view).unwrap();
@@ -30,11 +32,15 @@ impl GridViewRevisionPad {
         Self { view, delta }
     }
 
-    pub fn from_delta(delta: Delta) -> CollaborateResult<Self> {
+
+    pub fn from_delta(view_id: &str, delta: Delta) -> CollaborateResult<Self> {
+        if delta.is_empty() {
+            return Ok(GridViewRevisionPad::new(view_id.to_owned(), view_id.to_owned()));
+        }
         let s = delta.content()?;
         let view: GridViewRevision = serde_json::from_str(&s).map_err(|e| {
             let msg = format!("Deserialize delta to GridViewRevision failed: {}", e);
-            tracing::error!("{}", s);
+            tracing::error!("parsing json: {}", s);
             CollaborateError::internal().context(msg)
         })?;
         Ok(Self {
@@ -43,9 +49,15 @@ impl GridViewRevisionPad {
         })
     }
 
+<<<<<<< HEAD
     pub fn from_revisions(_grid_id: &str, revisions: Vec<Revision>) -> CollaborateResult<Self> {
         let delta: Delta = make_text_delta_from_revisions(revisions)?;
         Self::from_delta(delta)
+=======
+    pub fn from_revisions(view_id: &str, revisions: Vec<Revision>) -> CollaborateResult<Self> {
+        let delta: TextDelta = make_text_delta_from_revisions(revisions)?;
+        Self::from_delta(view_id, delta)
+>>>>>>> 01dbc68d4 (chore: fix open application error when upgrade to 0.0.5.1)
     }
 
     pub fn get_groups_by_field_revs(&self, field_revs: &[Arc<FieldRevision>]) -> Option<GroupConfigurationsByFieldId> {