Sha256: 320d68006309866abd9fa3631a25ab46a92d4005d646194b277c3ca9a1c4b011

Contents?: true

Size: 846 Bytes

Versions: 34

Compression:

Stored size: 846 Bytes

Contents

require 'singleton'

module Scrivito
  module Migrations
    class WorkspaceLock
      include Singleton

      def validate(workspace)
        unless exists? && workspace.revision_id == File.read(filename)
          raise ScrivitoError.new("There is a migration in progress right now. \
            Please try again after the migration working copy '#{workspace.id}' has \
            been published or removed.")
        end
      end

      def write(workspace)
        File.open(filename, 'w') do |file|
          file.write(workspace.revision_id)
        end
      end

      def remove
        if exists?
          File.delete(filename)
        end
      end

      def exists?
        File.exists?(filename)
      end

      private

      def filename
        File.join(Rails.root, 'tmp/migration_store.lock')
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
scrivito_sdk-0.65.2 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.65.1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.65.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.65.0.rc2 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.65.0.rc1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.60.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.60.0.rc2 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.50.1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.60.0.rc1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.50.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.50.0.rc2 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.50.0.rc1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.42.1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.42.1.rc3 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.42.1.rc2 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.42.1.rc1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.42.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.41.1 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.41.0 lib/scrivito/migrations/workspace_lock.rb
scrivito_sdk-0.41.0.rc2 lib/scrivito/migrations/workspace_lock.rb