作者 邓超

1

@@ -270,7 +270,7 @@ function sync($worker_id=0){ @@ -270,7 +270,7 @@ function sync($worker_id=0){
270 }else{ 270 }else{
271 foreach ($folder as $item){ 271 foreach ($folder as $item){
272 // 同步子文件夹 272 // 同步子文件夹
273 - $mailServer->syncMail($id,$item['id'],$folder['origin_folder'].'/'.$item['origin_folder']); 273 + $mailServer->syncMail($id,$item['id'],$item['origin_folder']);
274 } 274 }
275 } 275 }
276 276
@@ -56,27 +56,31 @@ class Mail { @@ -56,27 +56,31 @@ class Mail {
56 56
57 // $db->transaction(); 57 // $db->transaction();
58 foreach ($folders as $folder){ 58 foreach ($folders as $folder){
  59 + $pid = 0;
  60 + $uuid = md5($email_id.$folder['folder']);
  61 +
59 // 处理子父文件夹 62 // 处理子父文件夹
60 - $folder['id'] = explode('/',$folder['folder']); 63 + if(str_contains($folder['folder'], '/')){
  64 + // 子目录
61 $folder['name'] = explode('/',$folder['parseFolder']); 65 $folder['name'] = explode('/',$folder['parseFolder']);
62 - $pid = 0;  
63 - foreach ($folder['id'] as $k=>$item){  
64 - $data = [ 66 + // 查找pid
  67 + $pid = $db->value(folderSql::has(['uuid'=>md5($email_id.explode('/',$folder['folder'])[0])]));
  68 + // 去掉父目录名称
  69 + $folder['parseFolder'] = explode('/',$folder['parseFolder'])[1];
  70 + }
  71 +
  72 + try {
  73 + $db->insert(folderSql::$table,[
65 'email_id' => $email_id, 74 'email_id' => $email_id,
66 - 'folder' => $folder['name'][$k],  
67 - 'origin_folder' => $item, 75 + 'folder' => $folder['parseFolder'],
  76 + 'origin_folder' => $folder['folder'],
  77 + 'uuid' => $uuid,
68 'pid' => $pid 78 'pid' => $pid
69 - ];  
70 -  
71 - if(!$db->value(folderSql::has($data))){  
72 - // 插入到数据库  
73 - $pid = $db->insert(  
74 - folderSql::$table,  
75 - $data,  
76 - false  
77 - );  
78 - } 79 + ],false);
  80 + }catch (\Throwable $e){
  81 + // 这里就不处理失败了
79 } 82 }
  83 +
80 } 84 }
81 // $db->commit(); 85 // $db->commit();
82 86