forked from togettoyou/ipashare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7f377f
commit f11b7fa
Showing
5 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package sign | ||
|
||
import ( | ||
"path" | ||
"supersign/pkg/conf" | ||
"sync" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
var signJob *job | ||
|
||
type job struct { | ||
logger *zap.Logger | ||
streamCh chan *Stream | ||
doneCache map[string]*done | ||
mu sync.Mutex | ||
} | ||
|
||
type Stream struct { | ||
ProfileUUID string | ||
Iss string | ||
MobileprovisionPath string | ||
IpaUUID string | ||
BundleIdentifier string | ||
Version string | ||
Name string | ||
} | ||
|
||
type done struct { | ||
Success bool | ||
Msg string | ||
BundleIdentifier string | ||
Version string | ||
Name string | ||
} | ||
|
||
func Setup(logger *zap.Logger, maxJob int) { | ||
signJob = &job{ | ||
logger: logger, | ||
streamCh: make(chan *Stream, maxJob), | ||
doneCache: make(map[string]*done, 0), | ||
} | ||
go func() { | ||
for { | ||
select { | ||
case stream, ok := <-signJob.streamCh: | ||
if !ok { | ||
return | ||
} | ||
go func() { | ||
signJob.logger.Info("开始执行重签名任务......") | ||
err := run( | ||
path.Join(conf.Apple.AppleDeveloperPath, stream.Iss, "pem.pem"), | ||
path.Join(conf.Apple.AppleDeveloperPath, stream.Iss, "key.key"), | ||
stream.MobileprovisionPath, | ||
path.Join(conf.Apple.TemporaryFilePath, stream.ProfileUUID, "ipa.ipa"), | ||
path.Join(conf.Apple.UploadFilePath, stream.IpaUUID, "ipa.ipa"), | ||
) | ||
if err != nil { | ||
signJob.mu.Lock() | ||
defer signJob.mu.Unlock() | ||
signJob.doneCache[stream.ProfileUUID] = &done{ | ||
Success: false, | ||
Msg: "重签名任务执行失败:" + err.Error(), | ||
} | ||
signJob.logger.Error("重签名任务执行失败:" + err.Error()) | ||
return | ||
} | ||
signJob.mu.Lock() | ||
defer signJob.mu.Unlock() | ||
signJob.doneCache[stream.ProfileUUID] = &done{ | ||
Success: true, | ||
Msg: "重签名任务执行成功", | ||
BundleIdentifier: stream.BundleIdentifier, | ||
Version: stream.Version, | ||
Name: stream.Name, | ||
} | ||
signJob.logger.Info("重签名任务执行成功") | ||
}() | ||
} | ||
} | ||
}() | ||
} | ||
|
||
func Push(stream *Stream) { | ||
signJob.streamCh <- stream | ||
} | ||
|
||
func DoneCache(ProfileUUID string) (done *done, ok bool) { | ||
signJob.mu.Lock() | ||
defer signJob.mu.Unlock() | ||
done, ok = signJob.doneCache[ProfileUUID] | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters