コード例 #1
0
ファイル: dtc.go プロジェクト: kurze/dtc
func launchToServer(cIn chan StructFile) {
	var (
		err       error
		sf        StructFile
		dbF       *mgo.GridFile
		fi        os.FileInfo
		notClosed bool
		dbTime    time.Time
		fsTime    time.Time
	)

	for notClosed = true; notClosed; sf, notClosed = <-cIn {

		sf.Name = strings.Replace(sf.Name, dirName, "", 1)

		dbF = GetGridFile(sf.Name)
		if dbF == nil {
			log.Println("add : " + sf.Name)
			SetGridFile(sf)
		} else {

			dbTime = dbF.UploadDate()
			fi, err = sf.File.Stat()
			check(err)
			fsTime = fi.ModTime()

			if fsTime.After(dbTime) {
				log.Println("update : " + sf.Name)
				UpdateGridFile(sf)
			}
		}
	}
}