 
   savePacketSync: (id, packet) ->
     return unless id? and packet?
-    file = path.join(APPDATA, "#{id}.json")
-    data = JSON.stringify(packet)
-    fs.writeFileSync(file, data, FS_RW_OPTIONS)
-    @packetList.push(id)
+    try
+      name = "#{id}.json.gz"
+      fpath = path.join(APPDATA, name)
+      data = zlib.gzipSync(JSON.stringify(packet))
+      fs.writeFileSync(fpath, data)
+
+      @packetList.push(id)
+      @packetFile[id] =
+        name: name
+        packet: packet
+    catch error
+      console.error error
 
   loadPacket: (id, callback) ->
     return unless id? and callback?

fs = require 'fs-extra'
glob = require 'glob'
path = require 'path-extra'

# constant
window.APPDATA = path.join(window.APPDATA_PATH, 'battle-detail')
REFRESH_INTERVAL = 60000
FS_RW_OPTIONS =
  encoding: 'UTF-8'

# init
fs.ensureDir APPDATA, (error) ->

    # Use timestamp as id
    # from oldest to newest
    @packetList = []
    @packetFile = {}
    @packetListLastRefresh = 0

  # Packet Management
