瀏覽代碼

fix #704

tags/v2.1.0-rc1
Shivaram Lingamneni 4 年之前
父節點
當前提交
621df31577
共有 2 個檔案被更改,包括 27 行新增6 行删除
  1. 23
    5
      irc/channel.go
  2. 4
    1
      irc/server.go

+ 23
- 5
irc/channel.go 查看文件

211
 // ChannelManager's lock (that way, no one can join and make the channel dirty again
211
 // ChannelManager's lock (that way, no one can join and make the channel dirty again
212
 // between this method exiting and the actual deletion).
212
 // between this method exiting and the actual deletion).
213
 func (channel *Channel) IsClean() bool {
213
 func (channel *Channel) IsClean() bool {
214
+	config := channel.server.Config()
215
+
214
 	if !channel.writerSemaphore.TryAcquire() {
216
 	if !channel.writerSemaphore.TryAcquire() {
215
 		// a database write (which may fail) is in progress, the channel cannot be cleaned up
217
 		// a database write (which may fail) is in progress, the channel cannot be cleaned up
216
 		return false
218
 		return false
219
 
221
 
220
 	channel.stateMutex.RLock()
222
 	channel.stateMutex.RLock()
221
 	defer channel.stateMutex.RUnlock()
223
 	defer channel.stateMutex.RUnlock()
222
-	// the channel must be empty, and either be unregistered or fully written to the DB
223
-	return len(channel.members) == 0 && (channel.registeredFounder == "" || channel.dirtyBits == 0)
224
+	if len(channel.members) != 0 {
225
+		return false
226
+	}
227
+	if channel.registeredFounder == "" {
228
+		return true
229
+	}
230
+	// a registered channel must be fully written to the DB,
231
+	// and not set to ephemeral history (#704)
232
+	return channel.dirtyBits == 0 &&
233
+		channelHistoryStatus(config, true, channel.settings.History) != HistoryEphemeral
224
 }
234
 }
225
 
235
 
226
 func (channel *Channel) wakeWriter() {
236
 func (channel *Channel) wakeWriter() {
599
 	registered := channel.registeredFounder != ""
609
 	registered := channel.registeredFounder != ""
600
 	channel.stateMutex.RUnlock()
610
 	channel.stateMutex.RUnlock()
601
 
611
 
612
+	return channelHistoryStatus(config, registered, historyStatus), target
613
+}
614
+
615
+func channelHistoryStatus(config *Config, registered bool, storedStatus HistoryStatus) (result HistoryStatus) {
616
+	if !config.History.Enabled {
617
+		return HistoryDisabled
618
+	}
619
+
602
 	// ephemeral history: either the channel owner explicitly set the ephemeral preference,
620
 	// ephemeral history: either the channel owner explicitly set the ephemeral preference,
603
 	// or persistent history is disabled for unregistered channels
621
 	// or persistent history is disabled for unregistered channels
604
 	if registered {
622
 	if registered {
605
-		return historyEnabled(config.History.Persistent.RegisteredChannels, historyStatus), target
623
+		return historyEnabled(config.History.Persistent.RegisteredChannels, storedStatus)
606
 	} else {
624
 	} else {
607
 		if config.History.Persistent.UnregisteredChannels {
625
 		if config.History.Persistent.UnregisteredChannels {
608
-			return HistoryPersistent, target
626
+			return HistoryPersistent
609
 		} else {
627
 		} else {
610
-			return HistoryEphemeral, target
628
+			return HistoryEphemeral
611
 		}
629
 		}
612
 	}
630
 	}
613
 }
631
 }

+ 4
- 1
irc/server.go 查看文件

979
 		}
979
 		}
980
 	}
980
 	}
981
 
981
 
982
-	rb.Add(nil, target.server.name, RPL_LIST, target.nick, channel.name, strconv.Itoa(memberCount), channel.topic)
982
+	// #704: some channels are kept around even with no members
983
+	if memberCount != 0 {
984
+		rb.Add(nil, target.server.name, RPL_LIST, target.nick, channel.name, strconv.Itoa(memberCount), channel.topic)
985
+	}
983
 }
986
 }
984
 
987
 
985
 var (
988
 var (

Loading…
取消
儲存