|  |  | @ -309,6 +309,13 @@ func (ch *CaddyHugo) doc(r *http.Request) (*docref, error) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 			doc:    acedoc.NewString(string(contents)), |  |  |  | 			doc:    acedoc.NewString(string(contents)), | 
			
		
	
		
		
			
				
					
					|  |  |  | 			tmpdir: tmpdir, |  |  |  | 			tmpdir: tmpdir, | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		err = ref.doc.LogToFile(path.Join(ch.Site.Root, "logs", r.URL.Path[len("/hugo/edit/"):])) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if err != nil { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			fmt.Println(err) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			return nil, err | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		ch.docs[name] = ref |  |  |  | 		ch.docs[name] = ref | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 		hugoCmd := exec.Command("hugo", "--watch", "-D", "-d", ref.tmpdir) |  |  |  | 		hugoCmd := exec.Command("hugo", "--watch", "-D", "-d", ref.tmpdir) | 
			
		
	
	
		
		
			
				
					|  |  | @ -347,11 +354,12 @@ func (ch *CaddyHugo) doc(r *http.Request) (*docref, error) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 					idleTime := time.Duration(idleTicks) * WebsocketFileTicker |  |  |  | 					idleTime := time.Duration(idleTicks) * WebsocketFileTicker | 
			
		
	
		
		
			
				
					
					|  |  |  | 					if idleTime >= IdleWebsocketTimeout { |  |  |  | 					if idleTime >= IdleWebsocketTimeout { | 
			
		
	
		
		
			
				
					
					|  |  |  | 						err := ch.Publish() |  |  |  | 						err := ch.Publish() | 
			
		
	
		
		
			
				
					
					|  |  |  | 						fmt.Printf("idle for %v, quitting", idleTime) |  |  |  | 						fmt.Printf("idle for %v, quitting\n", idleTime) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 						if err != nil { |  |  |  | 						if err != nil { | 
			
		
	
		
		
			
				
					
					|  |  |  | 							fmt.Printf(", error publishing: %v\n", err) |  |  |  | 							fmt.Printf(", error publishing: %v\n", err) | 
			
		
	
		
		
			
				
					
					|  |  |  | 						} |  |  |  | 						} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						ref.doc.Close() | 
			
		
	
		
		
			
				
					
					|  |  |  | 						os.RemoveAll(tmpdir) |  |  |  | 						os.RemoveAll(tmpdir) | 
			
		
	
		
		
			
				
					
					|  |  |  | 						delete(ch.docs, name) |  |  |  | 						delete(ch.docs, name) | 
			
		
	
		
		
			
				
					
					|  |  |  | 						ch.mtx.Unlock() |  |  |  | 						ch.mtx.Unlock() | 
			
		
	
	
		
		
			
				
					|  |  | @ -421,6 +429,7 @@ func (ch *CaddyHugo) DeltaWebsocket(w http.ResponseWriter, r *http.Request) (int | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	defer func() { |  |  |  | 	defer func() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		ch.mtx.Lock() |  |  |  | 		ch.mtx.Lock() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		client.Close() | 
			
		
	
		
		
			
				
					
					|  |  |  | 		doc.clients-- |  |  |  | 		doc.clients-- | 
			
		
	
		
		
			
				
					
					|  |  |  | 		ch.mtx.Unlock() |  |  |  | 		ch.mtx.Unlock() | 
			
		
	
		
		
			
				
					
					|  |  |  | 	}() |  |  |  | 	}() | 
			
		
	
	
		
		
			
				
					|  |  | 
 |